diff --git a/Tests/images/one_strip.tif b/Tests/images/one_strip.tif new file mode 100644 index 000000000..6ed41e500 Binary files /dev/null and b/Tests/images/one_strip.tif differ diff --git a/Tests/test_file_libtiff.py b/Tests/test_file_libtiff.py index d6f4900cd..146d94119 100644 --- a/Tests/test_file_libtiff.py +++ b/Tests/test_file_libtiff.py @@ -869,6 +869,11 @@ class TestFileLibTiff(LibTiffTestCase): im.load() assert im.size == (950, 975) + def test_one_strip(self): + with Image.open("Tests/images/one_strip.tif") as im: + im.load() + assert im.size == (1728, 2344) + def test_orientation(self): with Image.open("Tests/images/g4_orientation_1.tif") as base_im: for i in range(2, 9): diff --git a/src/libImaging/TiffDecode.c b/src/libImaging/TiffDecode.c index 746994da3..ed9c2949f 100644 --- a/src/libImaging/TiffDecode.c +++ b/src/libImaging/TiffDecode.c @@ -328,7 +328,10 @@ _decodeStrip(Imaging im, ImagingCodecState state, TIFF *tiff) { int ret; ret = TIFFGetField(tiff, TIFFTAG_ROWSPERSTRIP, &rows_per_strip); - if (ret != 1) { + if ( + ret != 1 || + rows_per_strip == 4294967295 // 2 ** 32 - 1, the default + ) { rows_per_strip = state->ysize; } TRACE(("RowsPerStrip: %u \n", rows_per_strip)); @@ -564,7 +567,7 @@ ImagingLibTiffDecode( for (x = state->xoff; x < state->xsize; x += tile_width) { /* Sanity Check. Apparently in some cases, the TiffReadRGBA* functions have a different view of the size of the tiff than we're getting from - other functions. So, we need to check here. + other functions. So, we need to check here. */ if (!TIFFCheckTile(tiff, x, y, 0, 0)) { TRACE(("Check Tile Error, Tile at %dx%d\n", x, y));