Skip to content

Commit 2f84f63

Browse files
committed
Create disposal image at the destination size, instead of cropping
1 parent 16dbffc commit 2f84f63

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/PIL/GifImagePlugin.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,12 +265,15 @@ def _seek(self, frame):
265265
self.dispose = None
266266
elif self.disposal_method == 2:
267267
# replace with background colour
268-
Image._decompression_bomb_check(self.size)
269-
self.dispose = Image.core.fill("P", self.size, self.info["background"])
270268

271269
# only dispose the extent in this frame
272-
if self.dispose:
273-
self.dispose = self._crop(self.dispose, self.dispose_extent)
270+
x0, y0, x1, y1 = self.dispose_extent
271+
dispose_size = (x1 - x0, y1 - y0)
272+
273+
Image._decompression_bomb_check(dispose_size)
274+
self.dispose = Image.core.fill(
275+
"P", dispose_size, self.info["background"]
276+
)
274277
else:
275278
# replace with previous contents
276279
if self.im:

0 commit comments

Comments
 (0)