diff --git a/Tests/images/comment_after_only_frame.gif b/Tests/images/comment_after_only_frame.gif new file mode 100644 index 00000000000..8188b684732 Binary files /dev/null and b/Tests/images/comment_after_only_frame.gif differ diff --git a/Tests/test_file_gif.py b/Tests/test_file_gif.py index dbbd3bf9de9..68cb8a36e8d 100644 --- a/Tests/test_file_gif.py +++ b/Tests/test_file_gif.py @@ -399,6 +399,11 @@ def test_no_change(): assert im.is_animated assert_image_equal(im, expected) + with Image.open("Tests/images/comment_after_only_frame.gif") as im: + expected = Image.new("P", (1, 1)) + assert not im.is_animated + assert_image_equal(im, expected) + def test_eoferror(): with Image.open(TEST_GIF) as im: diff --git a/src/PIL/GifImagePlugin.py b/src/PIL/GifImagePlugin.py index c239a6a2bdb..2e11df54c0a 100644 --- a/src/PIL/GifImagePlugin.py +++ b/src/PIL/GifImagePlugin.py @@ -185,8 +185,6 @@ def _seek(self, frame, update_image=True): if not s or s == b";": raise EOFError - self.tile = [] - palette = None info = {} @@ -295,6 +293,8 @@ def _seek(self, frame, update_image=True): if not update_image: return + self.tile = [] + if self.dispose: self.im.paste(self.dispose, self.dispose_extent)