From 17ccfb2f5d3a697bb5adf93e780f41bf54a42496 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Tue, 29 Sep 2026 13:27:07 +1000 Subject: [PATCH] Revert "Corrected error when XMP is tuple" This reverts commit 4161bb1645fc66c9d587aafc53214f797831fa52. --- Tests/test_imageops.py | 9 --------- src/PIL/ImageOps.py | 14 +++++--------- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/Tests/test_imageops.py b/Tests/test_imageops.py index 4a4826d22e3..44b28d0fe56 100644 --- a/Tests/test_imageops.py +++ b/Tests/test_imageops.py @@ -484,15 +484,6 @@ def check(orientation_im: Image.Image) -> None: 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: with Image.open("Tests/images/xmp_tags_orientation.png") as im: assert im.getexif()[0x0112] == 3 diff --git a/src/PIL/ImageOps.py b/src/PIL/ImageOps.py index 593f801b031..1f513c719a6 100644 --- a/src/PIL/ImageOps.py +++ b/src/PIL/ImageOps.py @@ -754,15 +754,11 @@ def exif_transpose(image: Image.Image, *, in_place: bool = False) -> Image.Image r"([0-9])", ): value = exif_image.info[key] - if isinstance(value, str): - value = re.sub(pattern, "", value) - elif isinstance(value, tuple): - 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 + exif_image.info[key] = ( + re.sub(pattern, "", value) + if isinstance(value, str) + else re.sub(pattern.encode(), b"", value) + ) if not in_place: return transposed_image elif not in_place: