mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-15 11:00:52 +03:00
Use zero if background color index is missing
This commit is contained in:
parent
75c111903c
commit
3cb2413066
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 |
|
@ -853,3 +853,11 @@ def test_extents():
|
||||||
assert im.size == (100, 100)
|
assert im.size == (100, 100)
|
||||||
im.seek(1)
|
im.seek(1)
|
||||||
assert im.size == (150, 150)
|
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)
|
Image._decompression_bomb_check(dispose_size)
|
||||||
self.dispose = Image.core.fill(
|
self.dispose = Image.core.fill(
|
||||||
"P", dispose_size, self.info["background"]
|
"P", dispose_size, self.info.get("background", 0)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
# replace with previous contents
|
# replace with previous contents
|
||||||
if self.im:
|
if self.im:
|
||||||
# only dispose the extent in this frame
|
# only dispose the extent in this frame
|
||||||
self.dispose = self._crop(self.im, self.dispose_extent)
|
self.dispose = self._crop(self.im, self.dispose_extent)
|
||||||
except (AttributeError, KeyError):
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if interlace is not None:
|
if interlace is not None:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user