Prefer global transparency for disposal method 2

This commit is contained in:
Andrew Murray 2021-10-12 09:45:52 +11:00
parent 2d7c487cf8
commit 174b4893f3
3 changed files with 10 additions and 5 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@ -337,6 +337,13 @@ def test_dispose_background():
pass pass
def test_dispose_background_transparency():
with Image.open("Tests/images/dispose_bgnd_transparency.gif") as img:
img.seek(2)
px = img.convert("RGBA").load()
assert px[35, 30][3] == 0
def test_transparent_dispose(): def test_transparent_dispose():
expected_colors = [(2, 1, 2), (0, 1, 0), (2, 1, 2)] expected_colors = [(2, 1, 2), (0, 1, 0), (2, 1, 2)]
with Image.open("Tests/images/transparent_dispose.gif") as img: with Image.open("Tests/images/transparent_dispose.gif") as img:

View File

@ -271,11 +271,9 @@ class GifImageFile(ImageFile.ImageFile):
Image._decompression_bomb_check(dispose_size) Image._decompression_bomb_check(dispose_size)
# by convention, attempt to use transparency first # by convention, attempt to use transparency first
color = ( color = self.info.get("transparency", frame_transparency)
frame_transparency if color is None:
if frame_transparency is not None color = self.info.get("background", 0)
else self.info.get("background", 0)
)
self.dispose = Image.core.fill("P", dispose_size, color) self.dispose = Image.core.fill("P", dispose_size, color)
else: else:
# replace with previous contents # replace with previous contents