diff --git a/Tests/images/apng/dispose_op_background_p_mode.png b/Tests/images/apng/dispose_op_background_p_mode.png new file mode 100644 index 00000000000..e5fb4784d26 Binary files /dev/null and b/Tests/images/apng/dispose_op_background_p_mode.png differ diff --git a/Tests/test_file_apng.py b/Tests/test_file_apng.py index 1fd7d8c3d22..0eca786900a 100644 --- a/Tests/test_file_apng.py +++ b/Tests/test_file_apng.py @@ -104,6 +104,13 @@ def test_apng_dispose_region(): assert im.getpixel((64, 32)) == (0, 255, 0, 255) +def test_apng_dispose_op_background_p_mode(): + with Image.open("Tests/images/apng/dispose_op_background_p_mode.png") as im: + im.seek(1) + im.load() + assert im.size == (128, 64) + + def test_apng_blend(): with Image.open("Tests/images/apng/blend_op_source_solid.png") as im: im.seek(im.n_frames - 1) diff --git a/src/PIL/PngImagePlugin.py b/src/PIL/PngImagePlugin.py index 2cbc93093cd..e027953dd56 100644 --- a/src/PIL/PngImagePlugin.py +++ b/src/PIL/PngImagePlugin.py @@ -904,7 +904,7 @@ def load_end(self): dispose = self._prev_im.copy() dispose = self._crop(dispose, self.dispose_extent) elif self.dispose_op == APNG_DISPOSE_OP_BACKGROUND: - dispose = Image.core.fill("RGBA", self.size, (0, 0, 0, 0)) + dispose = Image.core.fill(self.im.mode, self.size) dispose = self._crop(dispose, self.dispose_extent) else: dispose = None