Ensure previous FLI frame is loaded before seeking to the next

This commit is contained in:
Andrew Murray 2018-11-26 18:52:51 +11:00
parent 080bfd3ee1
commit 2f7f945c84
3 changed files with 10 additions and 0 deletions

BIN
Tests/images/a_fli.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -85,6 +85,13 @@ class TestFileFli(PillowTestCase):
layer_number = im.tell()
self.assertEqual(layer_number, 1)
def test_seek(self):
im = Image.open(animated_test_file)
im.seek(50)
expected = Image.open("Tests/images/a_fli.png")
self.assert_image_equal(im, expected)
if __name__ == '__main__':
unittest.main()

View File

@ -131,6 +131,9 @@ class FliImageFile(ImageFile.ImageFile):
self.__frame = -1
self.__fp.seek(self.__rewind)
self.__offset = 128
else:
# ensure that the previous frame was loaded
self.load()
if frame != self.__frame + 1:
raise ValueError("cannot seek to frame %d" % frame)