Skip to content

Use transparency when combining P frames from APNGs#8443

Merged
hugovk merged 1 commit intopython-pillow:mainfrom
radarhere:apng_p_transparency
Oct 6, 2024
Merged

Use transparency when combining P frames from APNGs#8443
hugovk merged 1 commit intopython-pillow:mainfrom
radarhere:apng_p_transparency

Conversation

@radarhere
Copy link
Copy Markdown
Member

Helps #8440

When subsequent frames are loaded from an APNG image, transparency is considered for RGB core images, but not for P core images.

if self.im.mode == "RGB" and "transparency" in self.info:
mask = updated.convert_transparent(
"RGBA", self.info["transparency"]
)
else:
mask = updated.convert("RGBA")

This adds that, modelled after

Pillow/src/PIL/Image.py

Lines 1100 to 1103 in 01bb78a

if isinstance(t, bytes):
self.im.putpalettealphas(t)
elif isinstance(t, int):
self.im.putpalettealpha(t, 0)

@hugovk hugovk merged commit 838e0fb into python-pillow:main Oct 6, 2024
@radarhere radarhere deleted the apng_p_transparency branch October 6, 2024 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants