diff --git a/Tests/test_file_libtiff.py b/Tests/test_file_libtiff.py index ac78b086965..69499ff6ba8 100644 --- a/Tests/test_file_libtiff.py +++ b/Tests/test_file_libtiff.py @@ -8,7 +8,7 @@ import pytest -from PIL import Image, ImageFilter, TiffImagePlugin, TiffTags, features +from PIL import Image, ImageFilter, ImageOps, TiffImagePlugin, TiffTags, features from PIL.TiffImagePlugin import SAMPLEFORMAT, STRIPOFFSETS, SUBIFD from .helper import ( @@ -1039,6 +1039,14 @@ def test_orientation(self): assert_image_similar(base_im, im, 0.7) + def test_exif_transpose(self): + with Image.open("Tests/images/g4_orientation_1.tif") as base_im: + for i in range(2, 9): + with Image.open("Tests/images/g4_orientation_" + str(i) + ".tif") as im: + im = ImageOps.exif_transpose(im) + + assert_image_similar(base_im, im, 0.7) + @pytest.mark.valgrind_known_error(reason="Backtrace in Python Core") def test_sampleformat_not_corrupted(self): # Assert that a TIFF image with SampleFormat=UINT tag is not corrupted diff --git a/src/PIL/ImageOps.py b/src/PIL/ImageOps.py index 17702778c13..1231ad6ebda 100644 --- a/src/PIL/ImageOps.py +++ b/src/PIL/ImageOps.py @@ -588,6 +588,7 @@ def exif_transpose(image, *, in_place=False): with the transposition applied. If there is no transposition, a copy of the image will be returned. """ + image.load() image_exif = image.getexif() orientation = image_exif.get(ExifTags.Base.Orientation) method = {