diff --git a/new_studio_to_reg/tools_to_xmps.py b/new_studio_to_reg/tools_to_xmps.py index 7b9045e..2cd56aa 100644 --- a/new_studio_to_reg/tools_to_xmps.py +++ b/new_studio_to_reg/tools_to_xmps.py @@ -23,13 +23,19 @@ def clearExifAndRotate(imagePath, rotate=90): return print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} {imagePath} 图片exif信息清除并且旋转...') - # 打开图像 - with Image.open(imagePath) as img: - # 使用RGB模式打开图像来丢弃可能存在的EXIF信息 - img = img.convert("RGB") - img = img.rotate(rotate,expand=True) - # 保存图像,保存时不会带有原始的任何元数据 - img.save(imagePath, quality=100) # 对于JPEG,可以调整质量参数 + # 打开图像 + try: + with Image.open(imagePath) as img: + # 使用RGB模式打开图像来丢弃可能存在的EXIF信息 + img = img.convert("RGB") + img = img.rotate(rotate,expand=True) + # 保存图像,保存时不会带有原始的任何元数据 + 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):