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.
Instead of manually downloading and installing netpbm
from GitHub, the recommended approach is to ensure your GOPATH
environment variable is set properly then issue a
go get github.com/spakin/netpbm
command.
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.
Copyright © 2015 Scott Pakin
The netpbm
and netpbm/npcolor
packages are released under the BSD 3-Clause License. Informally, this means you can do whatever you want with the code as long as you give me (Scott Pakin) credit for writing the original version.