Skip to content

Commit b3e13a5

Browse files
committed
Put upper limit on rows per strip
1 parent d5b4012 commit b3e13a5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/PIL/TiffImagePlugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1555,7 +1555,7 @@ def _save(im, fp, filename):
15551555
stride = len(bits) * ((im.size[0] * bits[0] + 7) // 8)
15561556
# aim for 64 KB strips when using libtiff writer
15571557
if libtiff:
1558-
rows_per_strip = (2 ** 16 + stride - 1) // stride
1558+
rows_per_strip = min((2 ** 16 + stride - 1) // stride, im.size[1])
15591559
else:
15601560
rows_per_strip = im.size[1]
15611561
strip_byte_counts = stride * rows_per_strip

0 commit comments

Comments
 (0)