Fixed bug when rewinding to a non-zero frame

This commit is contained in:
Andrew Murray 2019-03-16 20:02:24 +11:00
parent 21ff4114bd
commit 7dfbdc01f4
2 changed files with 11 additions and 0 deletions

View File

@ -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],

View File

@ -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