Merge pull request #5756 from radarhere/gif_transparency

This commit is contained in:
Hugo van Kemenade 2021-10-12 10:04:44 +03:00 committed by GitHub
commit ac74226de9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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
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():
expected_colors = [(2, 1, 2), (0, 1, 0), (2, 1, 2)]
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)
# by convention, attempt to use transparency first
color = (
frame_transparency
if frame_transparency is not None
else self.info.get("background", 0)
)
color = self.info.get("transparency", frame_transparency)
if color is None:
color = self.info.get("background", 0)
self.dispose = Image.core.fill("P", dispose_size, color)
else:
# replace with previous contents