func Decode(r io.Reader) (image.Image, error)
Decode reads a PNG image from r and returns it as an image.Image. The type of Image returned depends on the PNG contents.
▹ Example
func DecodeConfig(r io.Reader) (image.Config, error)
DecodeConfig returns the color model and dimensions of a PNG image without decoding the entire image.
func Encode(w io.Writer, m image.Image) error
Encode writes the Image m to w in PNG format. Any Image may be encoded, but images that are not image.NRGBA might be encoded lossily.
▹ Example
CompressionLevel indicates the compression level.
type CompressionLevel int
const ( DefaultCompression CompressionLevel = 0 NoCompression CompressionLevel = -1 BestSpeed CompressionLevel = -2 BestCompression CompressionLevel = -3 )
Encoder configures encoding PNG images.
type Encoder struct { CompressionLevel CompressionLevel // BufferPool optionally specifies a buffer pool to get temporary // EncoderBuffers when encoding an image. BufferPool EncoderBufferPool // Go 1.9 }
func (enc *Encoder) Encode(w io.Writer, m image.Image) error
Encode writes the Image m to w in PNG format.
EncoderBuffer holds the buffers used for encoding PNG images.
type EncoderBuffer encoder
EncoderBufferPool is an interface for getting and returning temporary instances of the EncoderBuffer struct. This can be used to reuse buffers when encoding multiple images.
type EncoderBufferPool interface { Get() *EncoderBuffer Put(*EncoderBuffer) }
A FormatError reports that the input is not a valid PNG.
type FormatError string
func (e FormatError) Error() string
An UnsupportedError reports that the input uses a valid but unimplemented PNG feature.
type UnsupportedError string
func (e UnsupportedError) Error() string