When comparing frames in GifImagePlugin, use a frame unmodified by _get_palette_bytes

This commit is contained in:
Andrew Murray 2017-01-26 19:39:59 +11:00
parent da8f2737a8
commit 0ebb4cd1c0
2 changed files with 17 additions and 6 deletions

View File

@ -365,6 +365,7 @@ def _save(im, fp, filename, save_all=False):
# e.g. getdata(im_frame, duration=1000)
if not previous:
# global header
previous = im_frame.copy()
first_frame = getheader(im_frame, palette, encoderinfo)[0]
first_frame += getdata(im_frame, (0, 0), **encoderinfo)
else:
@ -386,7 +387,7 @@ def _save(im, fp, filename, save_all=False):
else:
# FIXME: what should we do in this case?
pass
previous = im_frame
previous = im_frame
if first_frame:
save_all = False
if not save_all:

View File

@ -406,10 +406,10 @@ class TestFileGif(PillowTestCase):
def test_transparent_optimize(self):
# from issue #2195, if the transparent color is incorrectly
# optimized out, gif loses transparency Need a palette that
# isn't using the 0 color, and one that's > 128 items where
# the transparent color is actually the top palette entry to
# trigger the bug.
# optimized out, gif loses transparency
# Need a palette that isn't using the 0 color, and one
# that's > 128 items where the transparent color is actually
# the top palette entry to trigger the bug.
from PIL import ImagePalette
@ -425,7 +425,17 @@ class TestFileGif(PillowTestCase):
reloaded = Image.open(out)
self.assertEqual(reloaded.info['transparency'], 253)
def test_bbox(self):
out = self.tempfile('temp.gif')
im = Image.new('RGB', (100,100), '#fff')
ims = [Image.new("RGB", (100,100), '#000')]
im.save(out, save_all=True, append_images=ims)
reread = Image.open(out)
self.assertEqual(reread.n_frames, 2)
if __name__ == '__main__':
unittest.main()