fix disable png info

This commit is contained in:
w-e-w 2023-05-29 07:30:32 +09:00
parent b957dcfece
commit 2aca613a61

View File

@ -511,9 +511,12 @@ def save_image_with_geninfo(image, geninfo, filename, extension=None, existing_p
existing_pnginfo['parameters'] = geninfo existing_pnginfo['parameters'] = geninfo
if extension.lower() == '.png': if extension.lower() == '.png':
pnginfo_data = PngImagePlugin.PngInfo() if opts.enable_pnginfo:
for k, v in (existing_pnginfo or {}).items(): pnginfo_data = PngImagePlugin.PngInfo()
pnginfo_data.add_text(k, str(v)) for k, v in (existing_pnginfo or {}).items():
pnginfo_data.add_text(k, str(v))
else:
pnginfo_data = None
image.save(filename, format=image_format, quality=opts.jpeg_quality, pnginfo=pnginfo_data) image.save(filename, format=image_format, quality=opts.jpeg_quality, pnginfo=pnginfo_data)