Python——添加照片边框

news2024/11/24 10:40:59

原图:

在这里插入图片描述

添加边框后:

在这里插入图片描述添加边框会读取照片的exif信息如时间、相机型号、品牌以及快门焦段等信息,将他们显示在下面的边框中。

获取当前py文件路径

import os
#get path that py file located
def Get_Currentpath():
    file_path = os.path.abspath(__file__)
    dir_path = os.path.dirname(file_path)
    return dir_path

弹窗获取所选择文件路径

如下图使用tkinter库掉出弹窗选择指定图片,并获取所选择图片的绝对路径

在这里插入图片描述

import tkinter 
#get file path that choosed
def Get_FilePath():
    root = tkinter.Tk()
    root.withdraw()
    f_path = filedialog.askopenfilename()
    return f_path

弹窗获取用户所选择的保存路径

将处理后的图片存储到所选的路径并指定文件名

在这里插入图片描述

def save_filePath():
    # 创建文件对话框
    root = tkinter.Tk()
    root.withdraw()
    # 弹出保存文件对话框
    file_path = filedialog.asksaveasfilename(defaultextension=".jpg", filetypes=[("JPG File", "*.jpg"), ("PNG file","*.png"),("All Files", "*.*")])
    print(file_path)
    # 如果用户选择了文件路径,则返回路径
    if file_path:
        return file_path
    else:
        pass

创建文字图片

def createfond(size=160,str=' ',color=(0,0,0)):
    lopath = Get_Currentpath()
    fondpath = lopath+r'\material\方正楷体简体.TTF'
    dignum=0
    alphanum=0
    othernum=0
    for i in str:
        if i.isdigit():
            dignum+=1
        elif i.isalpha():
            alphanum+=1
        else:
            othernum+=1`在这里插入代码片`
    othernum = len(str)-dignum
    x=int(dignum*size*0.6)+int(alphanum*size*0.6)+int(othernum*size*0.5)
    y=int(size*1.2)
    img = Image.new("RGBA",(x,y),'white')
    draw = ImageDraw.Draw(img)#创建一个绘画对象
    fnt = ImageFont.truetype(fondpath,size)
    draw.text((0,0),str,fill=color,font=fnt)
    #img.show()
    return img,x,y

获取字体ttf文件路径

fondpath = lopath+r'\material\方正楷体简体.TTF'

计算文字所占用的空间大小从而生成合适大小的image图像

   x=int(dignum*size*0.6)+int(alphanum*size*0.6)+int(othernum*size*0.5)
   y=int(size*1.2)
   img = Image.new("RGBA",(x,y),'white')

使用imageDraw 和 ImageFont方法在image图像上写文本

from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw    

draw = ImageDraw.Draw(img)#创建一个绘画对象
fnt = ImageFont.truetype(fondpath,size)
draw.text((0,0),str,fill=color,font=fnt)

生成文字图片如下
在这里插入图片描述

最后返回的是处理好的文本图像变量和图像的长和高

return img,x,y

创建边框

#creat the border
def CreateBorder(logopath,color = (255,255,255)):
    Src_path = Get_FilePath()
    pictype = picturetype.picturesize.size_16_9
    img = Image.open(Src_path)
    #get exif data
    exif_dict = piexif.load(Src_path)
    exif_bytes = piexif.dump(exif_dict)
    exif_mes = img._getexif()
    # 获取时间信息
    if "Exif" in exif_dict:
        exif_data = exif_dict["Exif"]
        #拍摄日期
        if piexif.ExifIFD.DateTimeOriginal in exif_data:
            datetime_original_0 = str(exif_data[piexif.ExifIFD.DateTimeOriginal].decode("utf-8"))
            #print("DateTimeOriginal:", datetime_original)
            datetime_original = datetime_original_0.replace(':','.',2)
            datetime_original = datetime_original[0:10]
            print(datetime_original)
        else:   
            datetime_original = ' '
        #焦距
        if piexif.ExifIFD.FocalLength in exif_data:
            FocalLength = str(int(exif_data[piexif.ExifIFD.FocalLength][0]/100))+"mm"
            #print("focal length:",FocalLength)
        else:
            FocalLength = ' '
        #ISO
        if piexif.ExifIFD.ISOSpeedRatings in exif_data:
            ISO = 'ISO'+str(exif_data[piexif.ExifIFD.ISOSpeedRatings])
            #print("ISO:",ISO)
        else:
            ISO = ' '
        #快门时间
        if piexif.ExifIFD.ExposureTime in exif_data:
            exposure_time = exif_data[piexif.ExifIFD.ExposureTime]
            shutter_speed = exposure_time[0] / exposure_time[1]
            shutter_speed = int(1/shutter_speed)
            shutter_speed = '1/'+str(shutter_speed)+'s'
        else:
            shutter_speed = ' '
        #光圈
        if piexif.ExifIFD.FNumber in exif_data:
            f_number = exif_data[piexif.ExifIFD.FNumber]
            fnumber = 'f/'+str(int(f_number[0] / f_number[1]))
            #print("光圈",fnumber)
        else:
            fnumber = ' '
        #镜头品牌
        if piexif.ExifIFD.LensMake in exif_data:
            lensmaker = exif_data[piexif.ExifIFD.LensMake].decode("utf-8")
            #print('镜头品牌:',lensmaker)
        else:
            lensmaker = ' '
        #镜头型号
        if piexif.ExifIFD.LensModel in exif_data:
            lensmodel = exif_data[piexif.ExifIFD.LensModel].decode("utf-8")
            #print("镜头型号",lensmodel)
        else:
            lensmodel = ' '

        camera_model = str(exif_dict["0th"].get(piexif.ImageIFD.Model).decode("utf-8"))
        camera_make = str(exif_dict["0th"].get(piexif.ImageIFD.Make).decode("utf-8"))
        print(camera_make,camera_model)
        signature = "Photo by mohuijun"
    else:
        pass
    #get width and high
    PicWidth = img.size[0]
    PicHigh = img.size[1]
    #picture is 16:9
    if int(PicWidth/16)==int(PicHigh/9):
        pictype = picturetype.picturesize.size_16_9
        lowwidth = int(PicWidth/3*2-PicHigh)
        Highwidth = 0
        letfWidth = 0
        rightwidth = 0
        borderhigh = lowwidth
        borderwide = PicWidth
        
    logoimg = Image.open(logopath)
    logowidth = int(PicWidth/7)
    logohigh = int(logowidth/4.3)
    logoimg.thumbnail((logowidth,logohigh))
    #create new pic
    NewPicWidth = PicWidth + letfWidth + rightwidth
    NewPicHigh = PicHigh + Highwidth + lowwidth
    #logo location
    logo_x = int(borderwide/20*11)
    logo_y = int((borderhigh-logohigh)/2)+PicHigh
    #create new picture
    img_new = Image.new('RGB', (NewPicWidth, NewPicHigh), color)
    #create exif message
    img_focallength,focallengthwid,focallengthhigh = createfond(size=120,str=FocalLength)
    img_data,datawid,datahigh = createfond(size=90,str=signature+' on '+datetime_original,color=(120,120,120))
    img_ISO,ISOwid,ISOhigh = createfond(size=120,str=ISO)
    img_shuttime,shutwid,shuthigh = createfond(size=120,str=shutter_speed)
    img_FNnumber,FNnumberwid,FNnumberhigh = createfond(size=120,str=fnumber)
    img_Lens,lenwid,lenhigh = createfond(size=90,str=(lensmaker+'·'+lensmodel),color=(120,120,120))
    # create '|'
    img_symbal,symbalwid,symbalhigh = createfond(size=350,str='|',color=(180,180,180))
    #create camera mode
    img_camera,camerawid,camerahigh = createfond(150,str = camera_make+' '+camera_model)
    #create signature
    #img_signature,signaturewid,signaturehigh = createfond(size = 100,str = signature,color=(120,120,120))
    symbal_x = logo_x+logowidth
    symbal_y = int((borderhigh-symbalhigh)/2)+PicHigh
    #exif message location
    focallength_x = symbal_x+symbalwid
    focallength_y = symbal_y+int(symbalhigh/10)
    FNnumber_x = focallength_x+focallengthwid
    FNnumber_y = symbal_y+int(symbalhigh/10)
    shuttime_x = FNnumber_x+FNnumberwid
    shuttime_y = symbal_y+int(symbalhigh/10)
    ISO_x = shuttime_x+shutwid
    ISO_y = symbal_y+int(symbalhigh/10)
    data_x = focallength_x
    data_y = symbal_y+int(symbalhigh/3*2)
    Lens_x = 100
    Lens_y = symbal_y+int(symbalhigh/3*2)
    camera_x = 100
    camera_y = symbal_y+int(symbalhigh/5)
    img_new.paste(img, (letfWidth, Highwidth))
    #paste logo
    img_new.paste(logoimg,(logo_x,logo_y))
    #paste exif message
    img_new.paste(img_focallength,(focallength_x,focallength_y))
    #img_new.paste(img_data,(data_x,data_y))
    img_new.paste(img_FNnumber,(FNnumber_x,FNnumber_y))
    img_new.paste(img_ISO,(ISO_x,ISO_y))
    img_new.paste(img_shuttime,(shuttime_x,shuttime_y))
    img_new.paste(img_Lens,(Lens_x,Lens_y))
    img_new.paste(img_data,(data_x,data_y))
    img_new.paste(img_symbal,(symbal_x,symbal_y))
    img_new.paste(img_camera,(camera_x,camera_y))
    Des_path = save_filePath()
    try:
        img_new.save(Des_path,exif=exif_bytes)
    except:
        print("地址无效")

获取所选图像绝对路径并打开

  Src_path = Get_FilePath()
  pictype = picturetype.picturesize.size_16_9
  img = Image.open(Src_path)

使用piexif库获取图片的exif信息,得到拍摄时间、相机型号、光圈、快门等数据信息

import piexif


 #get exif data
exif_dict = piexif.load(Src_path)
exif_bytes = piexif.dump(exif_dict)
exif_mes = img._getexif()
# 获取时间信息
if "Exif" in exif_dict:
    exif_data = exif_dict["Exif"]
    #拍摄日期
    if piexif.ExifIFD.DateTimeOriginal in exif_data:
        datetime_original_0 = str(exif_data[piexif.ExifIFD.DateTimeOriginal].decode("utf-8"))
        #print("DateTimeOriginal:", datetime_original)
        datetime_original = datetime_original_0.replace(':','.',2)
        datetime_original = datetime_original[0:10]
        print(datetime_original)
    else:   
        datetime_original = ' '
    #焦距
    if piexif.ExifIFD.FocalLength in exif_data:
        FocalLength = str(int(exif_data[piexif.ExifIFD.FocalLength][0]/100))+"mm"
        #print("focal length:",FocalLength)
    else:
        FocalLength = ' '
    #ISO
    if piexif.ExifIFD.ISOSpeedRatings in exif_data:
        ISO = 'ISO'+str(exif_data[piexif.ExifIFD.ISOSpeedRatings])
        #print("ISO:",ISO)
    else:
        ISO = ' '
    #快门时间
    if piexif.ExifIFD.ExposureTime in exif_data:
        exposure_time = exif_data[piexif.ExifIFD.ExposureTime]
        shutter_speed = exposure_time[0] / exposure_time[1]
        shutter_speed = int(1/shutter_speed)
        shutter_speed = '1/'+str(shutter_speed)+'s'
    else:
        shutter_speed = ' '
    #光圈
    if piexif.ExifIFD.FNumber in exif_data:
        f_number = exif_data[piexif.ExifIFD.FNumber]
        fnumber = 'f/'+str(int(f_number[0] / f_number[1]))
        #print("光圈",fnumber)
    else:
        fnumber = ' '
    #镜头品牌
    if piexif.ExifIFD.LensMake in exif_data:
        lensmaker = exif_data[piexif.ExifIFD.LensMake].decode("utf-8")
        #print('镜头品牌:',lensmaker)
    else:
        lensmaker = ' '
    #镜头型号
    if piexif.ExifIFD.LensModel in exif_data:
        lensmodel = exif_data[piexif.ExifIFD.LensModel].decode("utf-8")
        #print("镜头型号",lensmodel)
    else:
        lensmodel = ' '

    camera_model = str(exif_dict["0th"].get(piexif.ImageIFD.Model).decode("utf-8"))
    camera_make = str(exif_dict["0th"].get(piexif.ImageIFD.Make).decode("utf-8"))
    print(camera_make,camera_model)
    signature = "Photo by mohuijun"
else:
    pass

获取图片的高和宽度,计算照片比例,如果原图为16:9则填充边框变成3:2

  #get width and high
  PicWidth = img.size[0]
  PicHigh = img.size[1]
  #picture is 16:9
  if int(PicWidth/16)==int(PicHigh/9):
      pictype = picturetype.picturesize.size_16_9
      lowwidth = int(PicWidth/3*2-PicHigh)
      Highwidth = 0
      letfWidth = 0
      rightwidth = 0
      borderhigh = lowwidth
      borderwide = PicWidth

依据相机品牌logo的路径获取相机品牌logo图像

    #get logo pic
    logoimg = Image.open(logopath)
    logowidth = int(PicWidth/7)
    logohigh = int(logowidth/4.3)
    logoimg.thumbnail((logowidth,logohigh))
    #create new pic
    NewPicWidth = PicWidth + letfWidth + rightwidth
    NewPicHigh = PicHigh + Highwidth + lowwidth
    #logo location
    logo_x = int(borderwide/20*11)
    logo_y = int((borderhigh-logohigh)/2)+PicHigh

在这里插入图片描述
创建一个信息图片image作为处理后的图片

    #create new picture
    img_new = Image.new('RGB', (NewPicWidth, NewPicHigh), color)

使用上面所述的创建文字图像方法依次创建相机信息的图像

    #create exif message
    img_focallength,focallengthwid,focallengthhigh = createfond(size=120,str=FocalLength)
    img_data,datawid,datahigh = createfond(size=90,str=signature+' on '+datetime_original,color=(120,120,120))
    img_ISO,ISOwid,ISOhigh = createfond(size=120,str=ISO)
    img_shuttime,shutwid,shuthigh = createfond(size=120,str=shutter_speed)
    img_FNnumber,FNnumberwid,FNnumberhigh = createfond(size=120,str=fnumber)
    img_Lens,lenwid,lenhigh = createfond(size=90,str=(lensmaker+'·'+lensmodel),color=(120,120,120))
    # create '|'
    img_symbal,symbalwid,symbalhigh = createfond(size=350,str='|',color=(180,180,180))
    #create camera mode
    img_camera,camerawid,camerahigh = createfond(150,str = camera_make+' '+camera_model)

计算文字图像需要摆放的位置

    symbal_x = logo_x+logowidth
    symbal_y = int((borderhigh-symbalhigh)/2)+PicHigh
    #exif message location
    focallength_x = symbal_x+symbalwid
    focallength_y = symbal_y+int(symbalhigh/10)
    FNnumber_x = focallength_x+focallengthwid
    FNnumber_y = symbal_y+int(symbalhigh/10)
    shuttime_x = FNnumber_x+FNnumberwid
    shuttime_y = symbal_y+int(symbalhigh/10)
    ISO_x = shuttime_x+shutwid
    ISO_y = symbal_y+int(symbalhigh/10)
    data_x = focallength_x
    data_y = symbal_y+int(symbalhigh/3*2)
    Lens_x = 100
    Lens_y = symbal_y+int(symbalhigh/3*2)
    camera_x = 100
    camera_y = symbal_y+int(symbalhigh/5)

效果图下
在这里插入图片描述

将所有文字图像和原图按照指定位置和大小复制到新的图像中

    #paste orignial picture
    img_new.paste(img, (letfWidth, Highwidth))
    #paste logo
    img_new.paste(logoimg,(logo_x,logo_y))
    #paste exif message
    img_new.paste(img_focallength,(focallength_x,focallength_y))
    #img_new.paste(img_data,(data_x,data_y))
    img_new.paste(img_FNnumber,(FNnumber_x,FNnumber_y))
    img_new.paste(img_ISO,(ISO_x,ISO_y))
    img_new.paste(img_shuttime,(shuttime_x,shuttime_y))
    img_new.paste(img_Lens,(Lens_x,Lens_y))
    img_new.paste(img_data,(data_x,data_y))
    img_new.paste(img_symbal,(symbal_x,symbal_y))
    img_new.paste(img_camera,(camera_x,camera_y))

获取保存路径并保存

    Des_path = save_filePath()
    try:
        img_new.save(Des_path,exif=exif_bytes)
    except:
        print("地址无效")

主函数 创建图片边框

Local_path = Get_Currentpath()
LOGOPATH = Local_path+r'\material\fujifilmlogo.jpg'
CreateBorder(logopath=LOGOPATH)

附全部代码

import tkinter 
import os
from tkinter import filedialog
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
import exifread
import piexif
#get path that py file located
def Get_Currentpath():
    file_path = os.path.abspath(__file__)
    dir_path = os.path.dirname(file_path)
    return dir_path
#get file path that choosed
def Get_FilePath():
    root = tkinter.Tk()
    root.withdraw()
    f_path = filedialog.askopenfilename()
    return f_path
#set path to  save
def save_filePath():
    # 创建文件对话框
    root = tkinter.Tk()
    root.withdraw()
    # 弹出保存文件对话框
    file_path = filedialog.asksaveasfilename(defaultextension=".jpg", filetypes=[("JPG File", "*.jpg"), ("PNG file","*.png"),("All Files", "*.*")])
    print(file_path)
    # 如果用户选择了文件路径,则返回路径
    if file_path:
        return file_path
    else:
        pass
#create font
def createfond(size=160,str=' ',color=(0,0,0)):
    lopath = Get_Currentpath()
    fondpath = lopath+r'\material\方正楷体简体.TTF'
    dignum=0
    alphanum=0
    othernum=0
    for i in str:
        if i.isdigit():
            dignum+=1
        elif i.isalpha():
            alphanum+=1
        else:
            othernum+=1
    othernum = len(str)-dignum
    x=int(dignum*size*0.6)+int(alphanum*size*0.6)+int(othernum*size*0.5)
    y=int(size*1.2)
    img = Image.new("RGBA",(x,y),'white')
    draw = ImageDraw.Draw(img)#创建一个绘画对象
    fnt = ImageFont.truetype(fondpath,size)
    draw.text((0,0),str,fill=color,font=fnt)
    #img.show()
    return img,x,y
#creat the border
def CreateBorder(logopath,color = (255,255,255)):
    Src_path = Get_FilePath()
    pictype = picturetype.picturesize.size_16_9
    img = Image.open(Src_path)
    #get exif data
    exif_dict = piexif.load(Src_path)
    exif_bytes = piexif.dump(exif_dict)
    exif_mes = img._getexif()
    # if exif_mes is not None:
    #         camera_info = exif_mes.get(0x010F)  # 0x010F表示相机品牌和型号的标记
    #         print(camera_info)
    # 获取时间信息
    if "Exif" in exif_dict:
        exif_data = exif_dict["Exif"]
        #拍摄日期
        if piexif.ExifIFD.DateTimeOriginal in exif_data:
            datetime_original_0 = str(exif_data[piexif.ExifIFD.DateTimeOriginal].decode("utf-8"))
            #print("DateTimeOriginal:", datetime_original)
            datetime_original = datetime_original_0.replace(':','.',2)
            datetime_original = datetime_original[0:10]
            print(datetime_original)
        else:   
            datetime_original = ' '
        #焦距
        if piexif.ExifIFD.FocalLength in exif_data:
            FocalLength = str(int(exif_data[piexif.ExifIFD.FocalLength][0]/100))+"mm"
            #print("focal length:",FocalLength)
        else:
            FocalLength = ' '
        #ISO
        if piexif.ExifIFD.ISOSpeedRatings in exif_data:
            ISO = 'ISO'+str(exif_data[piexif.ExifIFD.ISOSpeedRatings])
            #print("ISO:",ISO)
        else:
            ISO = ' '
        #快门时间
        if piexif.ExifIFD.ExposureTime in exif_data:
            exposure_time = exif_data[piexif.ExifIFD.ExposureTime]
            shutter_speed = exposure_time[0] / exposure_time[1]
            shutter_speed = int(1/shutter_speed)
            shutter_speed = '1/'+str(shutter_speed)+'s'
        else:
            shutter_speed = ' '
        #光圈
        if piexif.ExifIFD.FNumber in exif_data:
            f_number = exif_data[piexif.ExifIFD.FNumber]
            fnumber = 'f/'+str(int(f_number[0] / f_number[1]))
            #print("光圈",fnumber)
        else:
            fnumber = ' '
        #镜头品牌
        if piexif.ExifIFD.LensMake in exif_data:
            lensmaker = exif_data[piexif.ExifIFD.LensMake].decode("utf-8")
            #print('镜头品牌:',lensmaker)
        else:
            lensmaker = ' '
        #镜头型号
        if piexif.ExifIFD.LensModel in exif_data:
            lensmodel = exif_data[piexif.ExifIFD.LensModel].decode("utf-8")
            #print("镜头型号",lensmodel)
        else:
            lensmodel = ' '
        # if  piexif.ExifIFD. in exif_data:
        #     makernote = exif_data[piexif.ExifIFD.DeviceSettingDescription].decode("utf-8")
        #     print("相机:",makernote)
        #get camera mode
        camera_model = str(exif_dict["0th"].get(piexif.ImageIFD.Model).decode("utf-8"))
        #camera_model = camera_model[2:-1]
        camera_make = str(exif_dict["0th"].get(piexif.ImageIFD.Make).decode("utf-8"))
        #camera_make = camera_make[2:-1]
        print(camera_make,camera_model)
        #get camera maker
        #print("camera:",camera_model)
        signature = "Photo by mohuijun"
    else:
        pass
    #get width and high
    PicWidth = img.size[0]
    PicHigh = img.size[1]
    #picture is 16:9
    if int(PicWidth/16)==int(PicHigh/9):
        lowwidth = int(PicWidth/3*2-PicHigh)
        Highwidth = 0
        letfWidth = 0
        rightwidth = 0
        borderhigh = lowwidth
        borderwide = PicWidth
    #create border
    #get logo pic
    logoimg = Image.open(logopath)
    logowidth = int(PicWidth/7)
    logohigh = int(logowidth/4.3)
    logoimg.thumbnail((logowidth,logohigh))
    #create new pic
    NewPicWidth = PicWidth + letfWidth + rightwidth
    NewPicHigh = PicHigh + Highwidth + lowwidth
    #logo location
    logo_x = int(borderwide/20*11)
    logo_y = int((borderhigh-logohigh)/2)+PicHigh
    #create new picture
    img_new = Image.new('RGB', (NewPicWidth, NewPicHigh), color)
    #create exif message
    img_focallength,focallengthwid,focallengthhigh = createfond(size=120,str=FocalLength)
    img_data,datawid,datahigh = createfond(size=90,str=signature+' on '+datetime_original,color=(120,120,120))
    img_ISO,ISOwid,ISOhigh = createfond(size=120,str=ISO)
    img_shuttime,shutwid,shuthigh = createfond(size=120,str=shutter_speed)
    img_FNnumber,FNnumberwid,FNnumberhigh = createfond(size=120,str=fnumber)
    img_Lens,lenwid,lenhigh = createfond(size=90,str=(lensmaker+'·'+lensmodel),color=(120,120,120))
    # create '|'
    img_symbal,symbalwid,symbalhigh = createfond(size=350,str='|',color=(180,180,180))
    #create camera mode
    img_camera,camerawid,camerahigh = createfond(150,str = camera_make+' '+camera_model)
    #create signature
    #img_signature,signaturewid,signaturehigh = createfond(size = 100,str = signature,color=(120,120,120))
    symbal_x = logo_x+logowidth
    symbal_y = int((borderhigh-symbalhigh)/2)+PicHigh
    #exif message location
    focallength_x = symbal_x+symbalwid
    focallength_y = symbal_y+int(symbalhigh/10)
    FNnumber_x = focallength_x+focallengthwid
    FNnumber_y = symbal_y+int(symbalhigh/10)
    shuttime_x = FNnumber_x+FNnumberwid
    shuttime_y = symbal_y+int(symbalhigh/10)
    ISO_x = shuttime_x+shutwid
    ISO_y = symbal_y+int(symbalhigh/10)
    data_x = focallength_x
    data_y = symbal_y+int(symbalhigh/3*2)
    Lens_x = 100
    Lens_y = symbal_y+int(symbalhigh/3*2)
    # signature_x = 100
    # signature_y = Lens_y
    camera_x = 100
    camera_y = symbal_y+int(symbalhigh/5)
    #paste singnature picture
    #img_new.paste(img_signature,(signature_x,signature_y))
    #paste orignial picture
    img_new.paste(img, (letfWidth, Highwidth))
    #paste logo
    img_new.paste(logoimg,(logo_x,logo_y))
    #paste exif message
    img_new.paste(img_focallength,(focallength_x,focallength_y))
    #img_new.paste(img_data,(data_x,data_y))
    img_new.paste(img_FNnumber,(FNnumber_x,FNnumber_y))
    img_new.paste(img_ISO,(ISO_x,ISO_y))
    img_new.paste(img_shuttime,(shuttime_x,shuttime_y))
    img_new.paste(img_Lens,(Lens_x,Lens_y))
    img_new.paste(img_data,(data_x,data_y))
    img_new.paste(img_symbal,(symbal_x,symbal_y))
    img_new.paste(img_camera,(camera_x,camera_y))
    Des_path = save_filePath()
    try:
        img_new.save(Des_path,exif=exif_bytes)
    except:
        print("地址无效")
    
Local_path = Get_Currentpath()
LOGOPATH = Local_path+r'\material\fujifilmlogo.jpg'
CreateBorder(logopath=LOGOPATH)

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/878800.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

mysql主从复制搭建

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录 前言MySQL复制过程分为三部: 一、准备工作二、配置>主库Master三、配置>从库SlaveSlave_IO_Running: YesSlave_SQL_Running: Yes 四、测试至此&am…

htmlCSS-----弹性布局案例展示

目录 前言 效果展示 ​编辑 代码 思路分析 前言 上一期我们学习了弹性布局,那么这一期我们用弹性布局来写一个小案例,下面看代码(上一期链接html&CSS-----弹性布局_灰勒塔德的博客-CSDN博客) 效果展示 代码 html代码&am…

BeanFactoryApplicationContext之间的关系

1**.BeanFactory与ApplicationContext之间的关系** (1)从继承关系上来看: ​ BeanFactory它是ApplicationContext 的父接口 (2)从功能上来看: ​ BeanFactory才是spring中的核心容器,而Appli…

使用AffNet和HardNet进行图像匹配

一、说明 我们有一个任务是找到与给定查询图像最匹配的图像。首先,我们在OpenCV中尝试了使用SIFT描述符和基于Flann的匹配器的经典图像匹配。结果是完全错误的。然后是词袋...最后,找到了AffNet和HardNet。 二、关于AffNet和HardNet 本文专门介绍如何进…

什么是浮动(float)?如何清除浮动?

聚沙成塔每天进步一点点 ⭐ 专栏简介⭐ 浮动(Float)和清除浮动⭐ 浮动的使用⭐ 清除浮动1. 空元素法(Empty Element Method)2. 使用 Clearfix Hack3. 使用 Overflow ⭐ 写在最后 ⭐ 专栏简介 前端入门之旅:探索Web开发…

《Java-SE-第三十七章》之反射

前言 在你立足处深挖下去,就会有泉水涌出!别管蒙昧者们叫嚷:“下边永远是地狱!” 博客主页:KC老衲爱尼姑的博客主页 博主的github,平常所写代码皆在于此 共勉:talk is cheap, show me the code 作者是爪哇岛的新手,水平很有限&…

【Vue-Router】嵌套路由

footer.vue <template><div><router-view></router-view><hr><h1>我是父路由</h1><div><router-link to"/user">Login</router-link><router-link to"/user/reg" style"margin-left…

Selenium 测试用例编写

编写Selenium测试用例就是模拟用户在浏览器上的一系列操作&#xff0c;通过脚本来完成自动化测试。 编写测试用例的优势&#xff1a; 开源&#xff0c;免费。 支持多种浏览器 IE&#xff0c;Firefox&#xff0c;Chrome&#xff0c;Safari。 支持多平台 Windows&#xff0c;Li…

【C语言】const修饰普通变量和指针

大家好&#xff0c;我是苏貝&#xff0c;本篇博客是系列博客每日一题的第一篇&#xff0c;本系列的题都不会太难&#xff0c;如果大家对这种系列的博客感兴趣的话&#xff0c;可以给我一个赞&#x1f44d;吗&#xff0c;感谢❤️ 文章目录 一.const修饰普通变量二.const修饰指…

Spring事务控制

目录 1、什么是事务控制 2、编程式事务控制 2.1、简介 2.2、相关对象 2.2.1、PlatformTransactionManager 2.2.2、TransactionDefinition 2.2.2.1、事务隔离级别 2.2.2.2、事务传播行为 2.2.3、TransactionStatus 3、声明式事务控制 3.1、简介 3.2、区别 3.3、⭐作…

Unity实现异步加载场景

一&#xff1a;创建UGUI 首先我们在LoginCanvas登入面板下面创建一个Panel,取名为LoadScreen,再在loadScreen下面创建一个Image组件&#xff0c;放置背景图片&#xff0c;然后我们再在lpadScreen下面继续创建一个Slider,这个是用来加载进度条的&#xff0c;我们改名为LoadSlid…

【考研数学】概率论与数理统计 | 第一章——随机事件与概率(1)

文章目录 一、随机试验与随机事件1.1 随机试验1.2 样本空间1.3 随机事件 二、事件的运算与关系2.1 事件的运算2.2 事件的关系2.3 事件运算的性质 三、概率的公理化定义与概率的基本性质3.1 概率的公理化定义3.2 概率的基本性质 写在最后 一、随机试验与随机事件 1.1 随机试验 …

Docker-使用数据卷、文件挂载进行数据存储与共享

一、前言 默认情况下&#xff0c;在Docker容器内创建的所有文件都只能在容器内部使用。容器删除后&#xff0c;数据也跟着删除&#xff0c;虽然通常我们不会删除容器&#xff0c;但是一旦宿主机发生故障&#xff0c;我们重新创建容器恢复服务&#xff0c;那么之前容器创建的文…

Matlab图坐标轴数值负号改为减号(change the hyphen (-) into minus sign (−, “U+2212”))

在MATLAB中&#xff0c;坐标轴负数默认符号是 - &#xff0c;如下图所示 x 1:1:50; y sin(x); plot(x,y)可通过以下两语句将负号修改为减号&#xff1a; set(gca,defaultAxesTickLabelInterpreter,latex); yticklabels(strrep(yticklabels,-,$-$));或者 set(gca, TickLabe…

安装mmcv失败

安装mmcv时报错 pip install mmcv这里只需要按照提示升级一下pip就可以了 pip install --upgrade pip然后安装成功

OCT介绍和分类

前言&#xff1a;研究方向和OCT有关&#xff0c;为了方便以后回顾&#xff0c;所以整理了OCT相关的一些内容。 OCT介绍和分类 OCT介绍分类时域OCT频域OCT扫频OCT谱域OCT OCT介绍 名称&#xff1a;OCT、光学相干层析成像术、Optical Coherence Tomography。 概念&#xff1a;O…

添加vue devtools扩展工具+添加后F12不显示Vue图标

前言&#xff1a;在开启Vue学习之旅时&#xff0c;遇到问题两个问题&#xff0c;第一添加不上vue devtools扩展工具&#xff0c;第二添加完成后&#xff0c;F12不显示Vue图标。查阅了很多博客&#xff0c;自己解决了问题&#xff0c;故写此博客记录。如果你遇到和我一样的问题&…

Docker容器与虚拟化技术:Docker架构、镜像管理

目录 一、理论 1.Doker概述 2.Docker核心概念 3.Docker安装 4.Docker的镜像管理命令 二、实验 1.Docker安装 2.查看Docker信息 3.Docker的镜像管理命令 三、问题 1.如何注册Docker账号 2.如何设置Docker公共存储库 四、总结 一、理论 1.Doker概述 (1) IT架构 裸…

request发送http请求

今天正式开始为大家介绍接口自动化&#xff0c;相信很多做测试的朋友&#xff0c;都用过一些工具&#xff0c;比如jmeter&#xff0c;loadrunner&#xff0c;postman等等&#xff0c;所以今天先给那些基础不太好的同学&#xff0c;先讲讲postman如何来测接口以及如何用pthon代码…