Merge pull request #10808 from AUTOMATIC1111/fix-disable-png-info

fix disable png info
This commit is contained in:
AUTOMATIC1111 2023-05-31 19:20:19 +03:00 committed by AUTOMATIC
parent c63d46ceb8
commit 6427ffde4d

View File

@ -493,9 +493,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)