Python——添加照片边框

原图:

在这里插入图片描述

添加边框后:

在这里插入图片描述添加边框会读取照片的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_pathelse:pass

创建文字图片

def createfond(size=160,str=' ',color=(0,0,0)):lopath = Get_Currentpath()fondpath = lopath+r'\material\方正楷体简体.TTF'dignum=0alphanum=0othernum=0for i in str:if i.isdigit():dignum+=1elif i.isalpha():alphanum+=1else:othernum+=1`在这里插入代码片`othernum = len(str)-dignumx=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_9img = Image.open(Src_path)#get exif dataexif_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 = ' '#ISOif 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 highPicWidth = img.size[0]PicHigh = img.size[1]#picture is 16:9if int(PicWidth/16)==int(PicHigh/9):pictype = picturetype.picturesize.size_16_9lowwidth = int(PicWidth/3*2-PicHigh)Highwidth = 0letfWidth = 0rightwidth = 0borderhigh = lowwidthborderwide = PicWidthlogoimg = Image.open(logopath)logowidth = int(PicWidth/7)logohigh = int(logowidth/4.3)logoimg.thumbnail((logowidth,logohigh))#create new picNewPicWidth = PicWidth + letfWidth + rightwidthNewPicHigh = PicHigh + Highwidth + lowwidth#logo locationlogo_x = int(borderwide/20*11)logo_y = int((borderhigh-logohigh)/2)+PicHigh#create new pictureimg_new = Image.new('RGB', (NewPicWidth, NewPicHigh), color)#create exif messageimg_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 modeimg_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+logowidthsymbal_y = int((borderhigh-symbalhigh)/2)+PicHigh#exif message locationfocallength_x = symbal_x+symbalwidfocallength_y = symbal_y+int(symbalhigh/10)FNnumber_x = focallength_x+focallengthwidFNnumber_y = symbal_y+int(symbalhigh/10)shuttime_x = FNnumber_x+FNnumberwidshuttime_y = symbal_y+int(symbalhigh/10)ISO_x = shuttime_x+shutwidISO_y = symbal_y+int(symbalhigh/10)data_x = focallength_xdata_y = symbal_y+int(symbalhigh/3*2)Lens_x = 100Lens_y = symbal_y+int(symbalhigh/3*2)camera_x = 100camera_y = symbal_y+int(symbalhigh/5)img_new.paste(img, (letfWidth, Highwidth))#paste logoimg_new.paste(logoimg,(logo_x,logo_y))#paste exif messageimg_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_9img = 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 = ' '#ISOif 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 highPicWidth = img.size[0]PicHigh = img.size[1]#picture is 16:9if int(PicWidth/16)==int(PicHigh/9):pictype = picturetype.picturesize.size_16_9lowwidth = int(PicWidth/3*2-PicHigh)Highwidth = 0letfWidth = 0rightwidth = 0borderhigh = lowwidthborderwide = PicWidth

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

    #get logo piclogoimg = Image.open(logopath)logowidth = int(PicWidth/7)logohigh = int(logowidth/4.3)logoimg.thumbnail((logowidth,logohigh))#create new picNewPicWidth = PicWidth + letfWidth + rightwidthNewPicHigh = PicHigh + Highwidth + lowwidth#logo locationlogo_x = int(borderwide/20*11)logo_y = int((borderhigh-logohigh)/2)+PicHigh

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

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

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

    #create exif messageimg_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 modeimg_camera,camerawid,camerahigh = createfond(150,str = camera_make+' '+camera_model)

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

    symbal_x = logo_x+logowidthsymbal_y = int((borderhigh-symbalhigh)/2)+PicHigh#exif message locationfocallength_x = symbal_x+symbalwidfocallength_y = symbal_y+int(symbalhigh/10)FNnumber_x = focallength_x+focallengthwidFNnumber_y = symbal_y+int(symbalhigh/10)shuttime_x = FNnumber_x+FNnumberwidshuttime_y = symbal_y+int(symbalhigh/10)ISO_x = shuttime_x+shutwidISO_y = symbal_y+int(symbalhigh/10)data_x = focallength_xdata_y = symbal_y+int(symbalhigh/3*2)Lens_x = 100Lens_y = symbal_y+int(symbalhigh/3*2)camera_x = 100camera_y = symbal_y+int(symbalhigh/5)

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

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

    #paste orignial pictureimg_new.paste(img, (letfWidth, Highwidth))#paste logoimg_new.paste(logoimg,(logo_x,logo_y))#paste exif messageimg_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_pathelse:pass
#create font
def createfond(size=160,str=' ',color=(0,0,0)):lopath = Get_Currentpath()fondpath = lopath+r'\material\方正楷体简体.TTF'dignum=0alphanum=0othernum=0for i in str:if i.isdigit():dignum+=1elif i.isalpha():alphanum+=1else:othernum+=1othernum = len(str)-dignumx=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_9img = Image.open(Src_path)#get exif dataexif_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 = ' '#ISOif 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 modecamera_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 highPicWidth = img.size[0]PicHigh = img.size[1]#picture is 16:9if int(PicWidth/16)==int(PicHigh/9):lowwidth = int(PicWidth/3*2-PicHigh)Highwidth = 0letfWidth = 0rightwidth = 0borderhigh = lowwidthborderwide = PicWidth#create border#get logo piclogoimg = Image.open(logopath)logowidth = int(PicWidth/7)logohigh = int(logowidth/4.3)logoimg.thumbnail((logowidth,logohigh))#create new picNewPicWidth = PicWidth + letfWidth + rightwidthNewPicHigh = PicHigh + Highwidth + lowwidth#logo locationlogo_x = int(borderwide/20*11)logo_y = int((borderhigh-logohigh)/2)+PicHigh#create new pictureimg_new = Image.new('RGB', (NewPicWidth, NewPicHigh), color)#create exif messageimg_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 modeimg_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+logowidthsymbal_y = int((borderhigh-symbalhigh)/2)+PicHigh#exif message locationfocallength_x = symbal_x+symbalwidfocallength_y = symbal_y+int(symbalhigh/10)FNnumber_x = focallength_x+focallengthwidFNnumber_y = symbal_y+int(symbalhigh/10)shuttime_x = FNnumber_x+FNnumberwidshuttime_y = symbal_y+int(symbalhigh/10)ISO_x = shuttime_x+shutwidISO_y = symbal_y+int(symbalhigh/10)data_x = focallength_xdata_y = symbal_y+int(symbalhigh/3*2)Lens_x = 100Lens_y = symbal_y+int(symbalhigh/3*2)# signature_x = 100# signature_y = Lens_ycamera_x = 100camera_y = symbal_y+int(symbalhigh/5)#paste singnature picture#img_new.paste(img_signature,(signature_x,signature_y))#paste orignial pictureimg_new.paste(img, (letfWidth, Highwidth))#paste logoimg_new.paste(logoimg,(logo_x,logo_y))#paste exif messageimg_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.rhkb.cn/news/90144.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

软考:中级软件设计师:文件管理,索引文件结构,树型文件结构,位示图,数据传输方式,微内核

软考:中级软件设计师: 提示:系列被面试官问的问题,我自己当时不会,所以下来自己复盘一下,认真学习和总结,以应对未来更多的可能性 关于互联网大厂的笔试面试,都是需要细心准备的 (1…

sudo免密码设置以及设置失败解决方法

使用sudo visudo修改\etc\sudoers文件 打开后有很多已有的设置大致格式username ALL(ALL:ALL) ALL,都不要动! 在文件结尾加上一句话: username ALL(ALL:ALL) NOPASSWD: ALLusername就是目前你这个账户的名字,开机时会输密码登录…

数据库内日期类型数据大于小于条件查找注意事项

只传date格式的日期取查datetime的字段的话默认是 00:00:00 日期类型字符串需要使用 ’ ’ 单引号括住 使用大于小于条件查询某一天的日期数据 前后判断条件不能是同一天 一个例子 数据库内数据: 查询2023-08-14之后的数据: select * from tetst…

互联网发展历程:从中继器口不够到集线器的引入

互联网的发展,就像一场不断演进的技术盛宴,每一步的变革都在推动着我们的世界向前。然而,在网络的早期,一项重要的技术问题曾困扰着人们:当中继器的接口数量不足时,如何连接更多的设备?这时&…

移动端预览指定链接的pdf文件流

场景 直接展示外部系统返回的获取文件流时出现了跨域问题: 解决办法 1. 外部系统返回的请求头中调整(但是其他系统不会给你改的) 2. 我们系统后台获取文件流并转为新的文件流提供给前端 /** 获取传入url文件流 */ GetMapping("/get…

【MySQL】MySQL不走索引的情况分析

未建立索引 当数据表没有设计相关索引时,查询会扫描全表。 create table test_temp (test_id int auto_incrementprimary key,field_1 varchar(20) null,field_2 varchar(20) null,field_3 bigint null,create_date date null );expl…

springboot整合kafka多数据源

整合kafka多数据源 项目背景依赖配置生产者消费者消息体 项目背景 在很多与第三方公司对接的时候,或者处在不同的网络环境下,比如在互联网和政务外网的分布部署服务的时候,我们需要对接多台kafka来达到我们的业务需求,那么当kafk…

读书笔记 |【项目思维与管理】➾ 项目成为一种生存方式

读书笔记 |【项目思维与管理】➾ 项目成为一种生存方式 一、理解项目固有的挑战二、项目对企业的价值三、知识型企业的经营逻辑四、做项目管理的推进者 💖The Begin💖点点关注,收藏不迷路💖 项目无处不在,项目已经成为…

考研408 | 【计算机网络】 网络层

导图 网络层: 路由器功能:转发&路由选择 数据平面 数据平面执行的主要功能是根据转发表进行转发,这是路由器的本地动作。 控制平面 1.传统方法/每路由器法: 2.SDN方法(Software-Defined Networking) 控制平面中的…

【变形金刚01】attention和transformer所有信息

图1.来源:Arseny Togulev在Unsplash上的照片 一、说明 这是一篇 长文 ,几乎讨论了人们需要了解的有关注意力机制的所有信息,包括自我注意、查询、键、值、多头注意力、屏蔽多头注意力和转换器,包括有关 BERT 和 GPT 的一些细节。因…

Vue3 引用第三方Swiper内容触摸滑动简单应用

去官网查看更多教程→:Swiper官网 → 点击教程在vue中使用Swiper→ 在Vue中使用Swiper cd 到项目 安装Swiper: cnpm install --save swiper 安装指定版本 cnpm install --save swiper8.1.6 9.4.1 10.1.0…

excel 下载方法封装

1.首先需要拿到后端返回的URL下载地址 2.写个下载方法 // url 接口返回的下载地址。例如:https://cancer-research.oss-cn-beijing.aliyuncs.com/yuance-platform-permission/校内共享数据导入模板.xlsx // name 文件名称 例如: 校内共享数据导入模板 /…

若依vue -【 100 ~ 更 ~ 110 】

100 主子表代码生成详解 1 新建数据库表结构(主子表) -- ---------------------------- -- 客户表 -- ---------------------------- drop table if exists sys_customer; create table sys_customer (customer_id bigint(20) not null…

设计模式——建造者(Builder)模式

建造者模式(Builder Pattern),又叫生成器模式,是一种对象构建模式 它可以将复杂对象的建造过程抽象出来,使这个抽象过程的不同实现方法可以构造出不同表现的对象。建造者模式是一步一步创建一个复杂的对象,…

Elasticsearch的一些基本概念

文章目录 基本概念:文档和索引JSON文档元数据索引REST API 节点和集群节点Master eligible节点和Master节点Data Node 和 Coordinating Node其它节点 分片(Primary Shard & Replica Shard)分片的设定操作命令 基本概念:文档和索引 Elasticsearch是面…

【Unity造轮子】制作一个简单的2d抓勾效果(类似蜘蛛侠的技能)

前言 欢迎阅读本文,本文将向您介绍如何使用Unity游戏引擎来实现一个简单而有趣的2D抓勾效果,类似于蜘蛛侠的独特能力。抓勾效果是许多动作游戏和平台游戏中的常见元素,给玩家带来了无限的想象和挑战。 不需要担心,即使您是一…

车载智能座舱开发核心技术——SystemServer

SystemServer在车载开发中扮演着重要角色,它是Android系统的核心组件之一,负责管理和调度其他系统服务。我们这篇内容将对SystemServer技术进行深入解析,并以实战代码示例加以分析,帮助读者更好地理解和应用该技术。 一、SystemS…

leetcode 力扣刷题 旋转矩阵(循环过程边界控制)

力扣刷题 旋转矩阵 二维矩阵按圈遍历(顺时针 or 逆时针)遍历59. 旋转矩阵Ⅱ54. 旋转矩阵剑指 Offer 29. 顺时针打印矩阵 二维矩阵按圈遍历(顺时针 or 逆时针)遍历 下面的题目的主要考察点都是,二维数组从左上角开始顺…

Camx--概述

该部分代码主要位于 vendor/qcom/proprietary/ 目录下: 其中 camx 代表了通用功能性接口的代码实现集合(CamX),chi-cdk代表了可定制化需求的代码实现集合(CHI),从图中可以看出Camx部分对上作为H…

Typora常用手册

常用快捷键 加粗: Ctrl B 标题: Ctrl H 插入链接: Ctrl K 插入代码: Ctrl Shift C – 无法执行 行内代码: Ctrl Shift K 插入图片: Ctrl Shift I 无序列表:Ctrl Shift L – 无法执行…