aboutsummaryrefslogtreecommitdiffstats
path: root/modules/images.py
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2023-09-09 06:21:18 +0000
committerGitHub <noreply@github.com>2023-09-09 06:21:18 +0000
commit9e58e11ad4d414d3f36482705a1d79e02b2e7f01 (patch)
treef13de4710c7a09e2350c2858cf603325583854fb /modules/images.py
parent4c4d7dd01f77f021381a09cb18b4ca8a8b7734b1 (diff)
parentf593cbfec417a3ea40589fe64e7f8806c9a81e5a (diff)
downloadstable-diffusion-webui-gfx803-9e58e11ad4d414d3f36482705a1d79e02b2e7f01.tar.gz
stable-diffusion-webui-gfx803-9e58e11ad4d414d3f36482705a1d79e02b2e7f01.tar.bz2
stable-diffusion-webui-gfx803-9e58e11ad4d414d3f36482705a1d79e02b2e7f01.zip
Merge pull request #13028 from AUTOMATIC1111/fallback-invalid-exif
Add Fallback at images.read_info_from_image 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 5cf3c825..592dfacf 100644
--- a/modules/images.py
+++ b/modules/images.py
@@ -724,7 +724,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)