# Method Image.PNG.encode()

Method encode

  ``string` encode(`Image.Image` `image`)`
  ``string` encode(`Image.Image` `image`, `mapping` `options`)`

Description

  Encodes a PNG image.

Parameter `options`

  ``"alpha"` : `Image.Image`` | Use this image as alpha channel (Note: PNG alpha channel is grey. The values are calculated by (r+2g+b)/4.)
  ``"palette"` : `Image.Colortable`` | Use this as palette for pseudocolor encoding (Note: encoding with alpha channel and pseudocolor at the same time are not supported)
  ``"zlevel"` : `int(0..9)`` | The level of z-compression to be applied. Default is 8.
  ``"zstrategy"` : `int`` | The type of LZ77 strategy to be used. Possible values are `Gz.DEFAULT_STRATEGY`, `Gz.FILTERED`, `Gz.HUFFMAN_ONLY`, `Gz.RLE`, `Gz.FIXED`. Default is `Gz.DEFAULT_STRATEGY`.

See also

  __decode

Note

  Please read some about PNG files.