Treat previous contents of first frame as transparent

This commit is contained in:
Andrew Murray 2021-04-15 19:01:12 +10:00
parent 2f5687f886
commit a47072bcbe
4 changed files with 16 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 530 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -341,6 +341,14 @@ def test_dispose_previous():
pass
def test_dispose_previous_first_frame():
with Image.open("Tests/images/dispose_prev_first_frame.gif") as im:
im.seek(1)
assert_image_equal_tofile(
im, "Tests/images/dispose_prev_first_frame_seeked.gif"
)
def test_previous_frame_loaded():
with Image.open("Tests/images/dispose_none.gif") as img:
img.load()

View File

@ -277,6 +277,14 @@ class GifImageFile(ImageFile.ImageFile):
if self.im:
# only dispose the extent in this frame
self.dispose = self._crop(self.im, self.dispose_extent)
elif frame_transparency is not None:
x0, y0, x1, y1 = self.dispose_extent
dispose_size = (x1 - x0, y1 - y0)
Image._decompression_bomb_check(dispose_size)
self.dispose = Image.core.fill(
"P", dispose_size, frame_transparency
)
except AttributeError:
pass