Skip to content

Commit 5ca4877

Browse files
committed
Prevent TIFFRGBAImageBegin from applying image orientation
1 parent 5bff2f3 commit 5ca4877

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
@@ -1030,6 +1030,17 @@ def test_old_style_jpeg(self) -> None:
10301030
with Image.open("Tests/images/old-style-jpeg-compression.tif") as im:
10311031
assert_image_equal_tofile(im, "Tests/images/old-style-jpeg-compression.png")
10321032

1033+
def test_old_style_jpeg_orientation(self) -> None:
1034+
with open("Tests/images/old-style-jpeg-compression.tif", "rb") as fp:
1035+
data = fp.read()
1036+
1037+
# Set EXIF Orientation to 2
1038+
data = data[:102] + b"\x02" + data[103:]
1039+
1040+
with Image.open(io.BytesIO(data)) as im:
1041+
im = im.transpose(Image.Transpose.FLIP_LEFT_RIGHT)
1042+
assert_image_equal_tofile(im, "Tests/images/old-style-jpeg-compression.png")
1043+
10331044
def test_open_missing_samplesperpixel(self) -> None:
10341045
with Image.open(
10351046
"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)