Fixed loading non-RGBA mode images with dispose background

This commit is contained in:
Andrew Murray 2020-06-29 21:20:57 +10:00
parent 20282dd23c
commit cdf4936c07
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