diff --git a/Tests/images/dispose_none_load_end.gif b/Tests/images/dispose_none_load_end.gif new file mode 100644 index 00000000000..3c94eb1b6e0 Binary files /dev/null and b/Tests/images/dispose_none_load_end.gif differ diff --git a/Tests/images/dispose_none_load_end_second.gif b/Tests/images/dispose_none_load_end_second.gif new file mode 100644 index 00000000000..5d8462cebb8 Binary files /dev/null and b/Tests/images/dispose_none_load_end_second.gif differ diff --git a/Tests/test_file_gif.py b/Tests/test_file_gif.py index 90943ac8f69..833294d81dc 100644 --- a/Tests/test_file_gif.py +++ b/Tests/test_file_gif.py @@ -307,6 +307,20 @@ def test_dispose_none(): pass +def test_dispose_none_load_end(): + # Test image created with: + # + # im = Image.open("transparent.gif") + # im_rotated = im.rotate(180) + # im.save("dispose_none_load_end.gif", + # save_all=True, append_images=[im_rotated], disposal=[1,2]) + with Image.open("Tests/images/dispose_none_load_end.gif") as img: + img.seek(1) + + with Image.open("Tests/images/dispose_none_load_end_second.gif") as expected: + assert_image_equal(img, expected) + + def test_dispose_background(): with Image.open("Tests/images/dispose_bgnd.gif") as img: try: diff --git a/src/PIL/GifImagePlugin.py b/src/PIL/GifImagePlugin.py index 4ca5a697efe..95e300bd78c 100644 --- a/src/PIL/GifImagePlugin.py +++ b/src/PIL/GifImagePlugin.py @@ -301,13 +301,14 @@ def load_end(self): # if the disposal method is 'do not dispose', transparent # pixels should show the content of the previous frame - if self._prev_im and self.disposal_method == 1: + if self._prev_im and self._prev_disposal_method == 1: # we do this by pasting the updated area onto the previous # frame which we then use as the current image content updated = self._crop(self.im, self.dispose_extent) self._prev_im.paste(updated, self.dispose_extent, updated.convert("RGBA")) self.im = self._prev_im self._prev_im = self.im.copy() + self._prev_disposal_method = self.disposal_method def _close__fp(self): try: