Skip to content

Commit

Permalink
Do not ignore SyntaxError when saving EXIF data
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Dec 7, 2024
1 parent c40bcbf commit 5bc36a6
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/PIL/AvifImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,21 +169,15 @@ def _save(

icc_profile = info.get("icc_profile", im.info.get("icc_profile"))
exif = info.get("exif", im.info.get("exif"))
if isinstance(exif, Image.Exif):
exif = exif.tobytes()

exif_orientation = 0
if exif:
exif_data = Image.Exif()
try:
exif_data.load(exif)
except SyntaxError:
pass
if isinstance(exif, Image.Exif):
exif_data = exif
exif = exif.tobytes()
else:
orientation_tag = next(
k for k, v in ExifTags.TAGS.items() if v == "Orientation"
)
exif_orientation = exif_data.get(orientation_tag) or 0
exif_data = Image.Exif()
exif_data.load(exif)
exif_orientation = exif_data.get(ExifTags.Base.Orientation, 0)

xmp = info.get("xmp", im.info.get("xmp") or im.info.get("XML:com.adobe.xmp"))

Expand Down

0 comments on commit 5bc36a6

Please sign in to comment.