Use zero if background color index is missing

This commit is contained in:
Andrew Murray 2021-04-08 08:04:20 +10:00
parent 75c111903c
commit 3cb2413066
4 changed files with 10 additions and 2 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 660 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 950 B

View File

@ -853,3 +853,11 @@ def test_extents():
assert im.size == (100, 100)
im.seek(1)
assert im.size == (150, 150)
def test_missing_background():
# The Global Color Table Flag isn't set, so there is no background color index,
# but the disposal method is "Restore to background color"
with Image.open("Tests/images/missing_background.gif") as im:
im.seek(1)
assert_image_equal_tofile(im, "Tests/images/missing_background_first_frame.gif")

View File

@ -270,14 +270,14 @@ class GifImageFile(ImageFile.ImageFile):
Image._decompression_bomb_check(dispose_size)
self.dispose = Image.core.fill(
"P", dispose_size, self.info["background"]
"P", dispose_size, self.info.get("background", 0)
)
else:
# replace with previous contents
if self.im:
# only dispose the extent in this frame
self.dispose = self._crop(self.im, self.dispose_extent)
except (AttributeError, KeyError):
except AttributeError:
pass
if interlace is not None: