Skip to content

Commit

Permalink
Merge pull request #13028 from AUTOMATIC1111/fallback-invalid-exif
Browse files Browse the repository at this point in the history
Add Fallback at images.read_info_from_image if exif data was invalid
  • Loading branch information
AUTOMATIC1111 authored Sep 9, 2023
2 parents 4c4d7dd + f593cbf commit 9e58e11
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion modules/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9e58e11

Please sign in to comment.