I spotted an instance where pillow_avif is losing transparency information about PNG images with mode P and a custom transparency value.
Here's a sample program that reproduces the issue:
from PIL import Image, ImageDraw
import pillow_avif
# Draw a basic checkerboard image
im = Image.new("P", size=(100, 100))
draw = ImageDraw.Draw(im)
draw.rectangle(xy=[(0, 0), (50, 50)], fill=255)
draw.rectangle(xy=[(50, 50), (100, 100)], fill=255)
# Save the image as a PNG, marking the 0'th colour in the palette as transparent
im.save("checkerboard.png", transparency=0)
# Open the image, then save it as an AVIF
opened_im = Image.open("checkerboard.png")
opened_im.save("checkerboard.avif")
This is how the two images get rendered on my Mac. Notice that the PNG correctly has two transparent regions, whereas the AVIF is solid black:
I'm using pillow==10.3.0 and pillow-avif-plugin==1.4.3.
I spotted an instance where
pillow_avif
is losing transparency information about PNG images with modeP
and a customtransparency
value.Here's a sample program that reproduces the issue:
This is how the two images get rendered on my Mac. Notice that the PNG correctly has two transparent regions, whereas the AVIF is solid black:
I'm using
pillow==10.3.0
andpillow-avif-plugin==1.4.3
.