File 0016-Ensure-previous-FLI-frame-is-loaded.patch of Package python-Pillow
From 2f7f945c843c5d88c3fb6772536cce4e80c35622 Mon Sep 17 00:00:00 2001
From: Andrew Murray <radarhere@users.noreply.github.com>
Date: Mon, 26 Nov 2018 18:52:51 +1100
Subject: [PATCH] Ensure previous FLI frame is loaded before seeking to the
next
---
Tests/test_file_fli.py | 7 +++++++
src/PIL/FliImagePlugin.py | 3 +++
2 files changed, 10 insertions(+)
diff --git a/Tests/test_file_fli.py b/Tests/test_file_fli.py
index 142af3cec4..2375d3749a 100644
--- a/Tests/test_file_fli.py
+++ b/Tests/test_file_fli.py
@@ -18,6 +18,14 @@ def test_sanity(self):
self.assertEqual(im.size, (128, 128))
self.assertEqual(im.format, "FLI")
+ def test_seek(self):
+ im = Image.open("Tests/images/a.fli")
+ for i in xrange(50):
+ im.seek(i + 1)
+
+ expected = Image.open("Tests/images/a_fli.png")
+ self.assert_image_equal(im, expected)
+
if __name__ == '__main__':
unittest.main()
diff --git a/PIL/FliImagePlugin.py b/PIL/FliImagePlugin.py
index c78c8c622d..b1eb9ae4df 100644
--- a/PIL/FliImagePlugin.py
+++ b/PIL/FliImagePlugin.py
@@ -110,6 +110,9 @@ def seek(self, frame):
i += 1
def seek(self, frame):
+ if frame != 0:
+ # ensure that the previous frame was loaded
+ self.load()
if frame != self.frame + 1:
raise ValueError("cannot seek to frame %d" % frame)