If every tile covers the image, only use the last offset

This commit is contained in:
Andrew Murray 2025-03-18 00:21:08 +11:00
parent 33ce0140fb
commit 841ba163fd

View File

@ -1608,6 +1608,10 @@ class TiffImageFile(ImageFile.ImageFile):
raise ValueError(msg)
w = tilewidth
if w == xsize and h == ysize and self._planar_configuration != 2:
# Every tile covers the image. Only use the last offset
offsets = offsets[-1:]
for offset in offsets:
if x + w > xsize:
stride = w * sum(bps_tuple) / 8 # bytes per line
@ -1630,11 +1634,11 @@ class TiffImageFile(ImageFile.ImageFile):
args,
)
)
x = x + w
x += w
if x >= xsize:
x, y = 0, y + h
if y >= ysize:
x = y = 0
y = 0
layer += 1
else:
logger.debug("- unsupported data organization")