dongchangxi 11 months ago
parent
commit
95b4c7437b
  1. 20
      new_studio_to_reg/tools_to_xmps.py

20
new_studio_to_reg/tools_to_xmps.py

@ -23,13 +23,19 @@ def clearExifAndRotate(imagePath, rotate=90):
return return
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} {imagePath} 图片exif信息清除并且旋转...') print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} {imagePath} 图片exif信息清除并且旋转...')
# 打开图像 # 打开图像
with Image.open(imagePath) as img: try:
# 使用RGB模式打开图像来丢弃可能存在的EXIF信息 with Image.open(imagePath) as img:
img = img.convert("RGB") # 使用RGB模式打开图像来丢弃可能存在的EXIF信息
img = img.rotate(rotate,expand=True) img = img.convert("RGB")
# 保存图像,保存时不会带有原始的任何元数据 img = img.rotate(rotate,expand=True)
img.save(imagePath, quality=100) # 对于JPEG,可以调整质量参数 # 保存图像,保存时不会带有原始的任何元数据
img.save(imagePath, quality=100) # 对于JPEG,可以调整质量参数
except Exception as e:
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} {imagePath} 图片处理失败,原因:{e}')
#移除该张图片
os.remove(imagePath)
return
#如果老影棚没有做过旋转坐标的照片的,则要做一次旋转坐标 #如果老影棚没有做过旋转坐标的照片的,则要做一次旋转坐标
def rateImages(pid): def rateImages(pid):

Loading…
Cancel
Save