mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 01:04:29 +03:00
fixing xmp tag orientation generated by exiftool
This commit is contained in:
parent
ce7af49eed
commit
6e97da0260
BIN
Tests/images/xmp_orientation_exifool.png
Normal file
BIN
Tests/images/xmp_orientation_exifool.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
|
@ -351,6 +351,13 @@ def test_exif_transpose():
|
|||
transposed_im = ImageOps.exif_transpose(im)
|
||||
assert 0x0112 not in transposed_im.getexif()
|
||||
|
||||
# Orientation from "XML:com.adobe.xmp" info key (from exiftool)
|
||||
with Image.open("Tests/images/xmp_orientation_exiftool.png") as im:
|
||||
assert im.getexif()[0x0112] == 8
|
||||
|
||||
transposed_im = ImageOps.exif_transpose(im)
|
||||
assert 0x0112 not in transposed_im.getexif()
|
||||
|
||||
# Orientation from "Raw profile type exif" info key
|
||||
# This test image has been manually hexedited from exif_imagemagick.png
|
||||
# to have a different orientation
|
||||
|
|
|
@ -1407,6 +1407,12 @@ class Image:
|
|||
match = re.search(r'tiff:Orientation="([0-9])"', xmp_tags)
|
||||
if match:
|
||||
self._exif[0x0112] = int(match[1])
|
||||
else:
|
||||
match = re.search(
|
||||
r"<tiff:Orientation>([0-9])</tiff:Orientation>", xmp_tags
|
||||
)
|
||||
if match:
|
||||
self._exif[0x0112] = int(match[1])
|
||||
|
||||
return self._exif
|
||||
|
||||
|
|
|
@ -606,5 +606,10 @@ def exif_transpose(image):
|
|||
"",
|
||||
transposed_image.info["XML:com.adobe.xmp"],
|
||||
)
|
||||
transposed_image.info["XML:com.adobe.xmp"] = re.sub(
|
||||
r"<tiff:Orientation>([0-9])</tiff:Orientation>",
|
||||
"",
|
||||
transposed_image.info["XML:com.adobe.xmp"],
|
||||
)
|
||||
return transposed_image
|
||||
return image.copy()
|
||||
|
|
Loading…
Reference in New Issue
Block a user