mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-24 17:06:16 +03:00
If palette is present but not needed, do not use global palette
This commit is contained in:
parent
ae6520ccd6
commit
e6ffbfd8df
BIN
Tests/images/palette_not_needed_for_second_frame.gif
Normal file
BIN
Tests/images/palette_not_needed_for_second_frame.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 28 KiB |
|
@ -92,6 +92,12 @@ def test_l_mode_after_rgb():
|
|||
assert im.mode == "RGB"
|
||||
|
||||
|
||||
def test_palette_not_needed_for_second_frame():
|
||||
with Image.open("Tests/images/palette_not_needed_for_second_frame.gif") as im:
|
||||
im.seek(1)
|
||||
assert_image_similar(im, hopper("L").convert("RGB"), 8)
|
||||
|
||||
|
||||
def test_strategy():
|
||||
with Image.open("Tests/images/chi.gif") as im:
|
||||
expected_zero = im.convert("RGB")
|
||||
|
|
|
@ -274,6 +274,8 @@ class GifImageFile(ImageFile.ImageFile):
|
|||
p = self.fp.read(3 << bits)
|
||||
if self._is_palette_needed(p):
|
||||
palette = ImagePalette.raw("RGB", p)
|
||||
else:
|
||||
palette = False
|
||||
|
||||
# image data
|
||||
bits = self.fp.read(1)[0]
|
||||
|
@ -298,7 +300,7 @@ class GifImageFile(ImageFile.ImageFile):
|
|||
if self.dispose:
|
||||
self.im.paste(self.dispose, self.dispose_extent)
|
||||
|
||||
self._frame_palette = palette or self.global_palette
|
||||
self._frame_palette = palette if palette is not None else self.global_palette
|
||||
if frame == 0:
|
||||
if self._frame_palette:
|
||||
self.mode = (
|
||||
|
|
Loading…
Reference in New Issue
Block a user