mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-03-13 01:05:48 +03:00
Merge pull request #8792 from radarhere/xmp
Corrected exif_transpose error when XMP is tuple
This commit is contained in:
commit
721a2fe3b1
|
@ -448,6 +448,15 @@ def test_exif_transpose() -> None:
|
||||||
assert 0x0112 not in transposed_im.getexif()
|
assert 0x0112 not in transposed_im.getexif()
|
||||||
|
|
||||||
|
|
||||||
|
def test_exif_transpose_with_xmp_tuple() -> None:
|
||||||
|
with Image.open("Tests/images/xmp_tags_orientation.png") as im:
|
||||||
|
assert im.getexif()[0x0112] == 3
|
||||||
|
|
||||||
|
im.info["xmp"] = (b"test",)
|
||||||
|
transposed_im = ImageOps.exif_transpose(im)
|
||||||
|
assert 0x0112 not in transposed_im.getexif()
|
||||||
|
|
||||||
|
|
||||||
def test_exif_transpose_xml_without_xmp() -> None:
|
def test_exif_transpose_xml_without_xmp() -> None:
|
||||||
with Image.open("Tests/images/xmp_tags_orientation.png") as im:
|
with Image.open("Tests/images/xmp_tags_orientation.png") as im:
|
||||||
assert im.getexif()[0x0112] == 3
|
assert im.getexif()[0x0112] == 3
|
||||||
|
|
|
@ -729,11 +729,15 @@ def exif_transpose(image: Image.Image, *, in_place: bool = False) -> Image.Image
|
||||||
r"<tiff:Orientation>([0-9])</tiff:Orientation>",
|
r"<tiff:Orientation>([0-9])</tiff:Orientation>",
|
||||||
):
|
):
|
||||||
value = exif_image.info[key]
|
value = exif_image.info[key]
|
||||||
exif_image.info[key] = (
|
if isinstance(value, str):
|
||||||
re.sub(pattern, "", value)
|
value = re.sub(pattern, "", value)
|
||||||
if isinstance(value, str)
|
elif isinstance(value, tuple):
|
||||||
else re.sub(pattern.encode(), b"", value)
|
value = tuple(
|
||||||
|
re.sub(pattern.encode(), b"", v) for v in value
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
value = re.sub(pattern.encode(), b"", value)
|
||||||
|
exif_image.info[key] = value
|
||||||
if not in_place:
|
if not in_place:
|
||||||
return transposed_image
|
return transposed_image
|
||||||
elif not in_place:
|
elif not in_place:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user