Merge pull request #3478 from radarhere/fli

Ensure previous FLI frame is loaded before seeking to the next
This commit is contained in:
Hugo 2018-12-04 22:51:54 +02:00 committed by GitHub
commit 0c2e4840f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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)