Clone wiki

pil-117-fastpng / Home


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 ='transparent-rgba.png')
assert img.mode == 'RGBA'
img = img.quantize(256, Image.FASTOCTREE)
assert img.mode == 'P''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.