diff options
author | AUTOMATIC <16777216c@gmail.com> | 2022-09-13 19:23:55 +0300 |
---|---|---|
committer | AUTOMATIC <16777216c@gmail.com> | 2022-09-13 19:23:55 +0300 |
commit | b6b9faa779ca4239ef3c06abddd92d4520effd0e (patch) | |
tree | 1e84adb6c32c60c4321d82a0c80b201caa1f8e34 /modules/images.py | |
parent | eeabe62b4d6088c9beafa208bfcb831e5e9cbd92 (diff) |
add support for reading saved jpeg comments
Diffstat (limited to 'modules/images.py')
-rw-r--r-- | modules/images.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/modules/images.py b/modules/images.py index 2e8eb335..9d730a93 100644 --- a/modules/images.py +++ b/modules/images.py @@ -325,14 +325,16 @@ def save_image(image, path, basename, seed=None, prompt=None, extension='png', i if not os.path.exists(fullfn):
break
- if extension == "png":
- image.save(fullfn, quality=opts.jpeg_quality, pnginfo=pnginfo)
+ if extension.lower() in ("jpg", "jpeg"):
+ exif_bytes = piexif.dump({
+ "Exif": {
+ piexif.ExifIFD.UserComment: info.encode("utf8"),
+ }
+ })
else:
- exif_dict = { "Exif" : dict() }
- exif_dict["Exif"][piexif.ExifIFD.UserComment] = piexif.helper.UserComment.dump(
- info, encoding="unicode")
- exif_bytes = piexif.dump(exif_dict)
- image.save(fullfn, quality=opts.jpeg_quality, exif=exif_bytes)
+ exif_bytes = None
+
+ image.save(fullfn, quality=opts.jpeg_quality, pnginfo=pnginfo, exif=exif_bytes)
target_side_length = 4000
oversize = image.width > target_side_length or image.height > target_side_length
|