netpbm
is a package for the Go programming language that implements image decoders and encoders for the Netpbm image formats. The package supports all of the following:
-
All of the Netpbm image formats:
-
Both "raw" (binary) and "plain" (ASCII) files
-
Both 8-bit and 16-bit color channels
-
Any maximum per-color-channel value (up to what the given number of bits can represent)
-
Full compatibility with Go's
image
package- Implements the
image.Image
interface - Additionally defines
Opaque
,PixOffset
,Set
, andSubimage
methods (and color-model-specific variants ofAt
andSet
), like most of Go's standard image types
- Implements the
-
Automatic promotion of image formats, if desired
That last feature means that a program that expects to read a grayscale image can also be given a black-and-white image, and a program that expects to read a color image can also be given either a grayscale or a black-and-white image.
netpbm
is a Go module so it can be installed by running
go get github.com/spakin/netpbm
on the command line.
netpbm
works just like the standard image/gif
, image/jpeg
, and image/png
packages in that
import (
_ "github.com/spakin/netpbm"
)
will enable image.Decode
to import Netpbm image formats.
Various package-specific functions, types, interfaces, and methods are available only with a normal (not "_
") import
. A normal import
is needed both to export Netpbm images and to exert more precise control over the Netpbm variants that are allowed to be imported. See the netpbm
API documentation for details.