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) # e.g. getdata(im_frame, duration=1000)
if not previous: if not previous:
# global header # global header
previous = im_frame.copy()
first_frame = getheader(im_frame, palette, encoderinfo)[0] first_frame = getheader(im_frame, palette, encoderinfo)[0]
first_frame += getdata(im_frame, (0, 0), **encoderinfo) first_frame += getdata(im_frame, (0, 0), **encoderinfo)
else: else:

View File

@ -406,10 +406,10 @@ class TestFileGif(PillowTestCase):
def test_transparent_optimize(self): def test_transparent_optimize(self):
# from issue #2195, if the transparent color is incorrectly # from issue #2195, if the transparent color is incorrectly
# optimized out, gif loses transparency Need a palette that # optimized out, gif loses transparency
# isn't using the 0 color, and one that's > 128 items where # Need a palette that isn't using the 0 color, and one
# the transparent color is actually the top palette entry to # that's > 128 items where the transparent color is actually
# trigger the bug. # the top palette entry to trigger the bug.
from PIL import ImagePalette from PIL import ImagePalette
@ -426,6 +426,16 @@ class TestFileGif(PillowTestCase):
self.assertEqual(reloaded.info['transparency'], 253) 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__': if __name__ == '__main__':
unittest.main() unittest.main()