mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-13 10:46:16 +03:00
Merge pull request #5390 from radarhere/gif_missing_background
Use zero if GIF background color index is missing
This commit is contained in:
commit
2f5687f886
BIN
Tests/images/missing_background.gif
Normal file
BIN
Tests/images/missing_background.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 660 B |
BIN
Tests/images/missing_background_first_frame.gif
Normal file
BIN
Tests/images/missing_background_first_frame.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 950 B |
|
@ -864,3 +864,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")
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue
Block a user