File tree Expand file tree Collapse file tree 4 files changed +18
-0
lines changed Expand file tree Collapse file tree 4 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -351,6 +351,13 @@ def check(orientation_im):
351351 transposed_im = ImageOps .exif_transpose (im )
352352 assert 0x0112 not in transposed_im .getexif ()
353353
354+ # Orientation from "XML:com.adobe.xmp" info key (from exiftool)
355+ with Image .open ("Tests/images/xmp_orientation_exiftool.png" ) as im :
356+ assert im .getexif ()[0x0112 ] == 8
357+
358+ transposed_im = ImageOps .exif_transpose (im )
359+ assert 0x0112 not in transposed_im .getexif ()
360+
354361 # Orientation from "Raw profile type exif" info key
355362 # This test image has been manually hexedited from exif_imagemagick.png
356363 # to have a different orientation
Original file line number Diff line number Diff line change @@ -1407,6 +1407,12 @@ def getexif(self):
14071407 match = re .search (r'tiff:Orientation="([0-9])"' , xmp_tags )
14081408 if match :
14091409 self ._exif [0x0112 ] = int (match [1 ])
1410+ else :
1411+ match = re .search (
1412+ r"<tiff:Orientation>([0-9])</tiff:Orientation>" , xmp_tags
1413+ )
1414+ if match :
1415+ self ._exif [0x0112 ] = int (match [1 ])
14101416
14111417 return self ._exif
14121418
Original file line number Diff line number Diff line change @@ -606,5 +606,10 @@ def exif_transpose(image):
606606 "" ,
607607 transposed_image .info ["XML:com.adobe.xmp" ],
608608 )
609+ transposed_image .info ["XML:com.adobe.xmp" ] = re .sub (
610+ r"<tiff:Orientation>([0-9])</tiff:Orientation>" ,
611+ "" ,
612+ transposed_image .info ["XML:com.adobe.xmp" ],
613+ )
609614 return transposed_image
610615 return image .copy ()
You can’t perform that action at this time.
0 commit comments