Skip to content

Commit 93cdfeb

Browse files
authored
Prevent TIFFRGBAImageBegin from applying image orientation (#8556)
Co-authored-by: Andrew Murray <[email protected]>
1 parent 6d42449 commit 93cdfeb

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

Tests/test_file_libtiff.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,17 @@ def test_old_style_jpeg(self) -> None:
10261026
with Image.open("Tests/images/old-style-jpeg-compression.tif") as im:
10271027
assert_image_equal_tofile(im, "Tests/images/old-style-jpeg-compression.png")
10281028

1029+
def test_old_style_jpeg_orientation(self) -> None:
1030+
with open("Tests/images/old-style-jpeg-compression.tif", "rb") as fp:
1031+
data = fp.read()
1032+
1033+
# Set EXIF Orientation to 2
1034+
data = data[:102] + b"\x02" + data[103:]
1035+
1036+
with Image.open(io.BytesIO(data)) as im:
1037+
im = im.transpose(Image.Transpose.FLIP_LEFT_RIGHT)
1038+
assert_image_equal_tofile(im, "Tests/images/old-style-jpeg-compression.png")
1039+
10291040
def test_open_missing_samplesperpixel(self) -> None:
10301041
with Image.open(
10311042
"Tests/images/old-style-jpeg-compression-no-samplesperpixel.tif"

src/libImaging/TiffDecode.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ _decodeAsRGBA(Imaging im, ImagingCodecState state, TIFF *tiff) {
299299
return -1;
300300
}
301301

302+
img.orientation = ORIENTATION_TOPLEFT;
302303
img.req_orientation = ORIENTATION_TOPLEFT;
303304
img.col_offset = 0;
304305

0 commit comments

Comments
 (0)