aboutsummaryrefslogtreecommitdiffstats
path: root/modules/images.py
diff options
context:
space:
mode:
authorAngelBottomless <aria1th@naver.com>2023-09-03 12:07:36 +0000
committerGitHub <noreply@github.com>2023-09-03 12:07:36 +0000
commitf593cbfec417a3ea40589fe64e7f8806c9a81e5a (patch)
tree58e51cfe2841831b8cb1f068233bd25e789c7d83 /modules/images.py
parentd39440bfb9d3b20338fc23a78e6655b1e2f7c1d5 (diff)
downloadstable-diffusion-webui-gfx803-f593cbfec417a3ea40589fe64e7f8806c9a81e5a.tar.gz
stable-diffusion-webui-gfx803-f593cbfec417a3ea40589fe64e7f8806c9a81e5a.tar.bz2
stable-diffusion-webui-gfx803-f593cbfec417a3ea40589fe64e7f8806c9a81e5a.zip
fallback if exif data was invalid
Diffstat (limited to 'modules/images.py')
-rw-r--r--modules/images.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/modules/images.py b/modules/images.py
index eb644733..8512a46e 100644
--- a/modules/images.py
+++ b/modules/images.py
@@ -718,7 +718,12 @@ def read_info_from_image(image: Image.Image) -> tuple[str | None, dict]:
geninfo = items.pop('parameters', None)
if "exif" in items:
- exif = piexif.load(items["exif"])
+ exif_data = items["exif"]
+ try:
+ exif = piexif.load(exif_data)
+ except OSError:
+ # memory / exif was not valid so piexif tried to read from a file
+ exif = None
exif_comment = (exif or {}).get("Exif", {}).get(piexif.ExifIFD.UserComment, b'')
try:
exif_comment = piexif.helper.UserComment.load(exif_comment)