Merge pull request #4742 from radarhere/apng_dispose

Fixed loading non-RGBA mode APNGs with dispose background
This commit is contained in:
Hugo van Kemenade 2020-06-29 17:15:34 +03:00 committed by GitHub
commit 645f7f2346
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -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)

View File

@ -904,7 +904,7 @@ class PngImageFile(ImageFile.ImageFile):
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