diff --git a/Tests/test_file_avif.py b/Tests/test_file_avif.py index b176ebde114..32dd694f580 100644 --- a/Tests/test_file_avif.py +++ b/Tests/test_file_avif.py @@ -327,6 +327,10 @@ def test_exif(self) -> None: exif = im.getexif() assert exif[274] == 1 + with Image.open("Tests/images/avif/xmp_tags_orientation.avif") as im: + exif = im.getexif() + assert exif[274] == 3 + def test_exif_save_default(self, tmp_path: Path) -> None: with Image.open("Tests/images/avif/exif.avif") as im: test_file = str(tmp_path / "temp.avif") diff --git a/src/PIL/Image.py b/src/PIL/Image.py index a49a38739f8..c00ab8a886d 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -1548,8 +1548,8 @@ def getexif(self) -> Exif: # XMP tags if ExifTags.Base.Orientation not in self._exif: - xmp_tags = self.info.get("XML:com.adobe.xmp") or self.info.get("xmp") - if isinstance(xmp_tags, bytes): + xmp_tags = self.info.get("XML:com.adobe.xmp") + if not xmp_tags and (xmp_tags := self.info.get("xmp")): xmp_tags = xmp_tags.decode("utf-8") if xmp_tags: match = re.search(r'tiff:Orientation(="|>)([0-9])', xmp_tags)