File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -974,6 +974,11 @@ def test_exif_hide_offsets(self) -> None:
974974 assert tag not in exif .get_ifd (0x8769 )
975975 assert exif .get_ifd (0xA005 )
976976
977+ def test_exif_from_xmp_bytes (self ) -> None :
978+ im = Image .new ("RGB" , (1 , 1 ))
979+ im .info ["xmp" ] = b'\xff tiff:Orientation="2"'
980+ assert im .getexif ()[274 ] == 2
981+
977982 def test_empty_xmp (self ) -> None :
978983 with Image .open ("Tests/images/hopper.gif" ) as im :
979984 if ElementTree is None :
Original file line number Diff line number Diff line change @@ -1542,10 +1542,11 @@ def getexif(self) -> Exif:
15421542 # XMP tags
15431543 if ExifTags .Base .Orientation not in self ._exif :
15441544 xmp_tags = self .info .get ("XML:com.adobe.xmp" )
1545+ pattern : str | bytes = r'tiff:Orientation(="|>)([0-9])'
15451546 if not xmp_tags and (xmp_tags := self .info .get ("xmp" )):
1546- xmp_tags = xmp_tags . decode ( "utf-8" )
1547+ pattern = rb'tiff:Orientation(="|>)([0-9])'
15471548 if xmp_tags :
1548- match = re .search (r'tiff:Orientation(="|>)([0-9])' , xmp_tags )
1549+ match = re .search (pattern , xmp_tags )
15491550 if match :
15501551 self ._exif [ExifTags .Base .Orientation ] = int (match [2 ])
15511552
You can’t perform that action at this time.
0 commit comments