diff --git a/PIL/GifImagePlugin.py b/PIL/GifImagePlugin.py index 60d6f49e4..6cf7a4f22 100644 --- a/PIL/GifImagePlugin.py +++ b/PIL/GifImagePlugin.py @@ -361,7 +361,7 @@ def _save(im, fp, filename, save_all=False): for im_frame in ImageSequence.Iterator(imSequence): encoderinfo = im.encoderinfo.copy() im_frame = _convert_mode(im_frame) - if isinstance(duration, list): + if isinstance(duration, (list, tuple)): encoderinfo["duration"] = duration[frame_count] frame_count += 1 diff --git a/Tests/test_file_gif.py b/Tests/test_file_gif.py index fdc7d9d55..cfaeb54ed 100644 --- a/Tests/test_file_gif.py +++ b/Tests/test_file_gif.py @@ -290,6 +290,8 @@ class TestFileGif(PillowTestCase): Image.new('L', (100, 100), '#111'), Image.new('L', (100, 100), '#222'), ] + + #duration as list im_list[0].save( out, save_all=True, @@ -305,6 +307,24 @@ class TestFileGif(PillowTestCase): except EOFError: pass + # duration as tuple + im_list[0].save( + out, + save_all=True, + append_images=im_list[1:], + duration=tuple(duration_list) + ) + reread = Image.open(out) + + for duration in duration_list: + self.assertEqual(reread.info['duration'], duration) + try: + reread.seek(reread.tell() + 1) + except EOFError: + pass + + + def test_number_of_loops(self): number_of_loops = 2