mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 09:26:16 +03:00
Use transparency when combining P frames
This commit is contained in:
parent
01bb78a8e7
commit
b77cd009e2
|
@ -258,8 +258,8 @@ def test_apng_mode() -> None:
|
|||
assert im.mode == "P"
|
||||
im.seek(im.n_frames - 1)
|
||||
im = im.convert("RGBA")
|
||||
assert im.getpixel((0, 0)) == (255, 0, 0, 0)
|
||||
assert im.getpixel((64, 32)) == (255, 0, 0, 0)
|
||||
assert im.getpixel((0, 0)) == (0, 255, 0, 255)
|
||||
assert im.getpixel((64, 32)) == (0, 255, 0, 255)
|
||||
|
||||
with Image.open("Tests/images/apng/mode_palette_1bit_alpha.png") as im:
|
||||
assert im.mode == "P"
|
||||
|
|
|
@ -1063,6 +1063,12 @@ class PngImageFile(ImageFile.ImageFile):
|
|||
"RGBA", self.info["transparency"]
|
||||
)
|
||||
else:
|
||||
if self.im.mode == "P" and "transparency" in self.info:
|
||||
t = self.info["transparency"]
|
||||
if isinstance(t, bytes):
|
||||
updated.putpalettealphas(t)
|
||||
elif isinstance(t, int):
|
||||
updated.putpalettealpha(t)
|
||||
mask = updated.convert("RGBA")
|
||||
self._prev_im.paste(updated, self.dispose_extent, mask)
|
||||
self.im = self._prev_im
|
||||
|
|
Loading…
Reference in New Issue
Block a user