Skip to content

Commit 841ba16

Browse files
committed
If every tile covers the image, only use the last offset
1 parent 33ce014 commit 841ba16

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/PIL/TiffImagePlugin.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,6 +1608,10 @@ def _setup(self) -> None:
16081608
raise ValueError(msg)
16091609
w = tilewidth
16101610

1611+
if w == xsize and h == ysize and self._planar_configuration != 2:
1612+
# Every tile covers the image. Only use the last offset
1613+
offsets = offsets[-1:]
1614+
16111615
for offset in offsets:
16121616
if x + w > xsize:
16131617
stride = w * sum(bps_tuple) / 8 # bytes per line
@@ -1630,11 +1634,11 @@ def _setup(self) -> None:
16301634
args,
16311635
)
16321636
)
1633-
x = x + w
1637+
x += w
16341638
if x >= xsize:
16351639
x, y = 0, y + h
16361640
if y >= ysize:
1637-
x = y = 0
1641+
y = 0
16381642
layer += 1
16391643
else:
16401644
logger.debug("- unsupported data organization")

0 commit comments

Comments
 (0)