diff --git a/Tests/test_imageops.py b/Tests/test_imageops.py index ff2445a51..8f72202eb 100644 --- a/Tests/test_imageops.py +++ b/Tests/test_imageops.py @@ -302,6 +302,7 @@ def test_exif_transpose(): else: assert transposed_im.info["exif"] != original_exif + assert 0x0112 in im.getexif() assert 0x0112 not in transposed_im.getexif() # Repeat the operation to test that it does not keep transposing diff --git a/src/PIL/ImageOps.py b/src/PIL/ImageOps.py index f9c35b2c6..8260c1a31 100644 --- a/src/PIL/ImageOps.py +++ b/src/PIL/ImageOps.py @@ -578,7 +578,8 @@ def exif_transpose(image): }.get(orientation) if method is not None: transposed_image = image.transpose(method) - del exif[0x0112] - transposed_image.info["exif"] = exif.tobytes() + transposed_exif = transposed_image.getexif() + del transposed_exif[0x0112] + transposed_image.info["exif"] = transposed_exif.tobytes() return transposed_image return image.copy()