File tree 2 files changed +8
-2
lines changed
2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -975,6 +975,11 @@ def test_exif_hide_offsets(self) -> None:
975
975
assert tag not in exif .get_ifd (0x8769 )
976
976
assert exif .get_ifd (0xA005 )
977
977
978
+ def test_exif_from_xmp_bytes (self ) -> None :
979
+ im = Image .new ("RGB" , (1 , 1 ))
980
+ im .info ["xmp" ] = b'\xff tiff:Orientation="2"'
981
+ assert im .getexif ()[274 ] == 2
982
+
978
983
def test_empty_xmp (self ) -> None :
979
984
with Image .open ("Tests/images/hopper.gif" ) as im :
980
985
if ElementTree is None :
Original file line number Diff line number Diff line change @@ -1538,10 +1538,11 @@ def getexif(self) -> Exif:
1538
1538
# XMP tags
1539
1539
if ExifTags .Base .Orientation not in self ._exif :
1540
1540
xmp_tags = self .info .get ("XML:com.adobe.xmp" )
1541
+ pattern : str | bytes = r'tiff:Orientation(="|>)([0-9])'
1541
1542
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])'
1543
1544
if xmp_tags :
1544
- match = re .search (r'tiff:Orientation(="|>)([0-9])' , xmp_tags )
1545
+ match = re .search (pattern , xmp_tags )
1545
1546
if match :
1546
1547
self ._exif [ExifTags .Base .Orientation ] = int (match [2 ])
1547
1548
You can’t perform that action at this time.
0 commit comments