Skip to content

Commit

Permalink
Simplified code by only setting info["exif"] once
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Dec 14, 2024
1 parent 938f413 commit 1608719
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/PIL/AvifImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,21 @@ def _open(self) -> None:

if icc:
self.info["icc_profile"] = icc
if exif:
self.info["exif"] = exif
if xmp:
self.info["xmp"] = xmp

if exif_orientation != 1 or exif is not None:
if exif_orientation != 1 or exif:
exif_data = Image.Exif()
orig_orientation = 1
if exif is not None:
if exif:
exif_data.load(exif)
orig_orientation = exif_data.get(ExifTags.Base.Orientation, 1)
if exif_orientation != orig_orientation:
original_orientation = exif_data.get(ExifTags.Base.Orientation, 1)
else:
original_orientation = 1
if exif_orientation != original_orientation:
exif_data[ExifTags.Base.Orientation] = exif_orientation
self.info["exif"] = exif_data.tobytes()
exif = exif_data.tobytes()
if exif:
self.info["exif"] = exif

def seek(self, frame: int) -> None:
if not self._seek_check(frame):
Expand Down

0 comments on commit 1608719

Please sign in to comment.