mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2024-06-07 21:20:49 +00:00
fix for failing to save 4chan downscale for large iamges
This commit is contained in:
parent
b28cf84c36
commit
6d2eb339d6
@ -345,16 +345,17 @@ def save_image(image, path, basename, seed=None, prompt=None, extension='png', i
|
|||||||
if not os.path.exists(fullfn):
|
if not os.path.exists(fullfn):
|
||||||
break
|
break
|
||||||
|
|
||||||
if extension.lower() in ("jpg", "jpeg", "webp"):
|
def exif_bytes():
|
||||||
exif_bytes = piexif.dump({
|
return piexif.dump({
|
||||||
"Exif": {
|
"Exif": {
|
||||||
piexif.ExifIFD.UserComment: piexif.helper.UserComment.dump(info, encoding="unicode")
|
piexif.ExifIFD.UserComment: piexif.helper.UserComment.dump(info or "", encoding="unicode")
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
else:
|
|
||||||
exif_bytes = None
|
|
||||||
|
|
||||||
image.save(fullfn, quality=opts.jpeg_quality, pnginfo=pnginfo, exif=exif_bytes)
|
if extension.lower() in ("jpg", "jpeg", "webp"):
|
||||||
|
image.save(fullfn, quality=opts.jpeg_quality, exif_bytes=exif_bytes())
|
||||||
|
else:
|
||||||
|
image.save(fullfn, quality=opts.jpeg_quality, pnginfo=pnginfo)
|
||||||
|
|
||||||
target_side_length = 4000
|
target_side_length = 4000
|
||||||
oversize = image.width > target_side_length or image.height > target_side_length
|
oversize = image.width > target_side_length or image.height > target_side_length
|
||||||
@ -366,7 +367,7 @@ def save_image(image, path, basename, seed=None, prompt=None, extension='png', i
|
|||||||
elif oversize:
|
elif oversize:
|
||||||
image = image.resize((image.width * target_side_length // image.height, target_side_length), LANCZOS)
|
image = image.resize((image.width * target_side_length // image.height, target_side_length), LANCZOS)
|
||||||
|
|
||||||
image.save(fullfn, quality=opts.jpeg_quality, exif=exif_bytes)
|
image.save(fullfn_without_extension + ".jpg", quality=opts.jpeg_quality, exif_bytes=exif_bytes())
|
||||||
|
|
||||||
if opts.save_txt and info is not None:
|
if opts.save_txt and info is not None:
|
||||||
with open(f"{fullfn_without_extension}.txt", "w", encoding="utf8") as file:
|
with open(f"{fullfn_without_extension}.txt", "w", encoding="utf8") as file:
|
||||||
|
Loading…
Reference in New Issue
Block a user