Wiki

Clone wiki

pil-117-fastpng / Home

FastPNG

This fork implements a new color quantizer and the ability to open and save paletted/8bit PNG images with full transparency support. With the new color quantizer, the PNG encoding performance is nearly on par with JPEG files.

How to use

img = Image.open('transparent-rgba.png')
assert img.mode == 'RGBA'
img = img.quantize(256, Image.FASTOCTREE)
assert img.mode == 'P'
img.save('transparent-p.png')

The PNG plugin detects if the palette has alpha values and automatically stores it. There is no need to pass a `transparency` parameter.

Updated