1
This commit is contained in:
1 parent
10f07e4a9c
commit
9362e5180e
1 file changed
+13
-7
@@ -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):
|
||||
|
||||
Reference in new issue
Block a user