diff --git a/Tests/test_file_gif.py b/Tests/test_file_gif.py index 6a4b14d40..838894988 100644 --- a/Tests/test_file_gif.py +++ b/Tests/test_file_gif.py @@ -230,6 +230,15 @@ class TestFileGif(PillowTestCase): self.assertEqual(im.info, info) + def test_seek_rewind(self): + im = Image.open("Tests/images/iss634.gif") + im.seek(2) + im.seek(1) + + expected = Image.open("Tests/images/iss634.gif") + expected.seek(1) + self.assert_image_equal(im, expected) + def test_n_frames(self): for path, n_frames in [ [TEST_GIF, 1], diff --git a/src/PIL/GifImagePlugin.py b/src/PIL/GifImagePlugin.py index 2ebd8b248..3dc13ac03 100644 --- a/src/PIL/GifImagePlugin.py +++ b/src/PIL/GifImagePlugin.py @@ -122,6 +122,8 @@ class GifImageFile(ImageFile.ImageFile): if not self._seek_check(frame): return if frame < self.__frame: + if frame != 0: + self.im = None self._seek(0) last_frame = self.__frame