Skip to content

tburke/netpbm

 
 

Repository files navigation

netpbm

Introduction

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 except for the newer PAM (portable arbitrary map) format:

    • PBM (portable bitmap): black and white only
    • PGM (portable graymap): grayscale
    • PPM (portable pixmap): color
  • 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, and Subimage methods (and color-model-specific variants of At and Set), like most of Go's standard image types
  • 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.

Installation

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.

Usage

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 and License

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.

Author

Scott Pakin, scott+npbm@pakin.org

About

Read and write Netpbm images from Go programs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%