PIL identifies, reads, and writes PNG files containing “1”, “L”, “P”, “RGB”, or “RGBA” data. Interlaced files are currently not supported.

The open method sets the following info properties, when appropriate:


Gamma, given as a floating point number.


Transparency colour index. This key is omitted if the image is not a transparent palette image.

The save method supports the following options:


If present, instructs the PNG writer to make the output file as small as possible. This includes extra processing in order to find optimal encoder settings.


For P and L images, this option controls what colour image to mark as transparent.

bits (experimental)

For P images, this option controls how many bits to store. If omitted, the PNG writer uses 8 bits (256 colors).

dictionary (experimental)

Set the ZLIB encoder dictionary.

Note: To enable PNG support, you need to build and install the ZLIB compression library before building the Python Imaging Library. See the distribution README for details.


A Django site. rendered by a django application. hosted by webfaction.