Use transparency when combining P frames from APNGs by radarhere · Pull Request #8443 · python-pillow/Pillow
Helps #8440
When subsequent frames are loaded from an APNG image, transparency is considered for RGB core images, but not for P core images.
Pillow/src/PIL/PngImagePlugin.py
Lines 1061 to 1066 in 01bb78a
| 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
Lines 1100 to 1103 in 01bb78a
| if isinstance(t, bytes): | |
| self.im.putpalettealphas(t) | |
| elif isinstance(t, int): | |
| self.im.putpalettealpha(t, 0) |