Documentation ¶
Overview ¶
Package pnm implements a PBM, PGM and PPM image decoder and encoder.
The decoder can read files in both plain and raw format with 8 or 16 bits per channel. The encoder can only write files in plain format with 8 bits per channel.
To only be able to load pnm images using image.Decode, use
import _ "github.com/UNO-SOFT/gopnm"
Not implemented are:
- Writing pnm files in raw format.
- Reading/and writing PAM images.
(I would be happy to accept patches for these.)
Specifications can be found at http://netpbm.sourceforge.net/doc/#formats.
Index ¶
Constants ¶
const ( PBM int = 0 PGM int = 1 PPM int = 2 )
Variables ¶
This section is empty.
Functions ¶
func Decode ¶
Decode reads a PNM image from r and returns it as an image.Image.
The type of Image returned depends on the PNM contents:
- PBM: image.Gray with black = 0 and white = 255
- PGM: image.Gray or image.Gray16, values as in the file
- PPM: image.RGBA or image.RGBA64, values as in the file
- PAM: not supported (yet)
func DecodeConfig ¶
DecodeConfig returns the color model and dimensions of a PNM image without decoding the entire image.
Types ¶
type PNMConfig ¶
func DecodeConfigPNM ¶
DecodeConfigPNM reads and returns header data of PNM files.
This may be useful to obtain the actual file type and for files that have a Maxval other than the maximum supported Maxval. To apply gamma correction this value is needed. Note that gamma correction is not performed by the decoder.