Handle default value for RowsPerStrip TIFF tag

This commit is contained in:
Andrew Murray 2021-03-25 17:04:31 +11:00
parent 759c518420
commit b541aff64a
3 changed files with 10 additions and 2 deletions

BIN
Tests/images/one_strip.tif Normal file

Binary file not shown.

View File

@ -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):

View File

@ -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));