Skip to content

spakin/netpbm

Repository files navigation

netpbm

GitHub Actions Go Report Card Go Reference

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:

    • PBM (portable bitmap): black and white only
    • PGM (portable graymap): grayscale
    • PPM (portable pixmap): color
    • PAM (portable arbitrary map): alpha
  • 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

netpbm is a Go module so it can be installed by running

go get github.com/spakin/netpbm

on the command line.

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.

Author

Scott Pakin, [email protected]

About

Read and write Netpbm images from Go programs

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages