Skip to content

Commit 0ae2981

Browse files
kmilosradarhere
authored andcommitted
Put upper limit on rows per strip
1 parent 1c4deef commit 0ae2981

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/PIL/TiffImagePlugin.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1560,7 +1560,7 @@ def _save(im, fp, filename):
15601560
stride = len(bits) * ((im.size[0] * bits[0] + 7) // 8)
15611561
# aim for 64 KB strips when using libtiff writer
15621562
if libtiff:
1563-
rows_per_strip = (2 ** 16 + stride - 1) // stride
1563+
rows_per_strip = min((2 ** 16 + stride - 1) // stride, im.size[1])
15641564
else:
15651565
rows_per_strip = im.size[1]
15661566
strip_byte_counts = stride * rows_per_strip

0 commit comments

Comments
 (0)