File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -973,6 +973,11 @@ def test_exif_hide_offsets(self) -> None:
973973 assert tag not in exif .get_ifd (0x8769 )
974974 assert exif .get_ifd (0xA005 )
975975
976+ def test_exif_from_xmp_bytes (self ) -> None :
977+ im = Image .new ("RGB" , (1 , 1 ))
978+ im .info ["xmp" ] = b'\xff tiff:Orientation="2"'
979+ assert im .getexif ()[274 ] == 2
980+
976981 def test_empty_xmp (self ) -> None :
977982 with Image .open ("Tests/images/hopper.gif" ) as im :
978983 if ElementTree is None :
Original file line number Diff line number Diff line change @@ -1538,10 +1538,11 @@ def getexif(self) -> Exif:
15381538 # XMP tags
15391539 if ExifTags .Base .Orientation not in self ._exif :
15401540 xmp_tags = self .info .get ("XML:com.adobe.xmp" )
1541+ pattern : str | bytes = r'tiff:Orientation(="|>)([0-9])'
15411542 if not xmp_tags and (xmp_tags := self .info .get ("xmp" )):
1542- xmp_tags = xmp_tags . decode ( "utf-8" )
1543+ pattern = rb'tiff:Orientation(="|>)([0-9])'
15431544 if xmp_tags :
1544- match = re .search (r'tiff:Orientation(="|>)([0-9])' , xmp_tags )
1545+ match = re .search (pattern , xmp_tags )
15451546 if match :
15461547 self ._exif [ExifTags .Base .Orientation ] = int (match [2 ])
15471548
You can’t perform that action at this time.
0 commit comments