diff options
author | AUTOMATIC <16777216c@gmail.com> | 2022-09-14 12:20:05 +0000 |
---|---|---|
committer | AUTOMATIC <16777216c@gmail.com> | 2022-09-14 12:20:05 +0000 |
commit | bb2732c1c7349490fe39f536e487c720449c85f7 (patch) | |
tree | cd2474229da1615825503bdc276fc145c52da2aa /modules/extras.py | |
parent | c4e90bf6893eb61cbc9f5a8bcc71aa4a2c344d8f (diff) | |
download | stable-diffusion-webui-gfx803-bb2732c1c7349490fe39f536e487c720449c85f7.tar.gz stable-diffusion-webui-gfx803-bb2732c1c7349490fe39f536e487c720449c85f7.tar.bz2 stable-diffusion-webui-gfx803-bb2732c1c7349490fe39f536e487c720449c85f7.zip |
updates for exif comments #446
Diffstat (limited to 'modules/extras.py')
-rw-r--r-- | modules/extras.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/modules/extras.py b/modules/extras.py index 55a782c7..e3c7d3e5 100644 --- a/modules/extras.py +++ b/modules/extras.py @@ -7,6 +7,7 @@ import modules.gfpgan_model from modules.ui import plaintext_to_html
import modules.codeformer_model
import piexif
+import piexif.helper
cached_images = {}
@@ -80,7 +81,12 @@ def run_pnginfo(image): if "exif" in image.info:
exif = piexif.load(image.info["exif"])
exif_comment = (exif or {}).get("Exif", {}).get(piexif.ExifIFD.UserComment, b'')
- exif_comment = exif_comment.decode("utf8", 'ignore')
+ try:
+ exif_comment = piexif.helper.UserComment.load(exif_comment)
+ except ValueError:
+ exif_comment = exif_comment.decode('utf8', errors="ignore")
+
+
items['exif comment'] = exif_comment
for field in ['jfif', 'jfif_version', 'jfif_unit', 'jfif_density', 'dpi', 'exif']:
|