From 93e0f80a22c1c3efd405d43f64ea8ea6e7d9f5e2 Mon Sep 17 00:00:00 2001 From: Steve Mc Gregor Date: Sun, 29 Nov 2020 20:38:48 -0800 Subject: [PATCH] APNG - use previous frame with dispose action to draw the next frame. APNG defines a dispose operation after each frame. This dispose should be done before drawing the next frame. PNG code stores this frame on _prev_im but it is not used to draw the next frame. This change use the _prev_im as the base to draw the next frame. --- src/PIL/PngImagePlugin.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/PIL/PngImagePlugin.py b/src/PIL/PngImagePlugin.py index 6af41af6e..fa897cefa 100644 --- a/src/PIL/PngImagePlugin.py +++ b/src/PIL/PngImagePlugin.py @@ -868,6 +868,11 @@ class PngImageFile(ImageFile.ImageFile): self.decoderconfig = self.decoderconfig + (1,) self.__idat = self.__prepare_idat # used by load_read() + + # Use prev_im as base image + if self.is_animated and self._prev_im: + self.im = self._prev_im.copy() + ImageFile.ImageFile.load_prepare(self) def load_read(self, read_bytes):