Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle default value for RowsPerStrip TIFF tag #5358

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file added Tests/images/one_strip.tif
Binary file not shown.
5 changes: 5 additions & 0 deletions Tests/test_file_libtiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,11 @@ def test_no_rows_per_strip(self):
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):
Expand Down
7 changes: 5 additions & 2 deletions src/libImaging/TiffDecode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand Down