From Wikipedia, the free encyclopedia
Jump to: navigation, search
Developer(s) Bryan Henderson
Initial release 1988; 26 years ago (1988)
Stable release 10.35.95 / 26 September 2014; 29 days ago (2014-09-26)
Written in C, Perl, Unix Shell
Operating system Cross-platform
License various, believed to be DFSG free

Netpbm is an open source package of graphics programs and a programming library, used mainly in the Unix world. It is included in all major open source Unix-like operating system distributions and also works on other Unix-like operating systems, Windows, Unix operating systems such as Mac OS X, and other platforms.

File formats and programs[edit]

Netpbm defines a set of graphics formats called the Netpbm formats:

Netpbm contains over 220 separate programs in the package, most of which have "pbm", "pgm", "ppm", "pam", or "pnm" in their names. For example, you might use pamscale to shrink an image by 10%, pamcomp to overlay one image on top of another, pbmtext to create an image of text or reduce the number of colors in an image with pnmquant.

The Netpbm package can, for example, use two successive conversion programs to turn a picture in the PBM format into a .bmp file:

pgmtoppm "#FFFFFF" somepic.pbm  > somepic.ppm
ppmtobmp somepic.ppm > somepic.bmp

This is more commonly done as a pipeline, to save execution time and to avoid leaving a temporary somepic.ppm file around:

pgmtoppm "#FFFFFF" somepic.pbm | ppmtobmp > somepic.bmp

The Netpbm programs are frequently used as intermediates to convert between obscure formats. For instance, there may be no tool to convert an X11 window dump (XWD format) directly to a Macintosh PICT file, but one can do this by running xwdtopnm, then ppmtopict. (Tools which say that they output PNM output either PBM, PGM or PPM. Tools importing PNM will read any of the three formats.) As a more complex example, Netpbm tools can convert 48×48 XBM to Ikon and eventually X-Face.[1]


The PBM (black and white) format was invented by Jef Poskanzer in the mid-1980s. At the time, there was no standard, reliable way to send binary files in email, and attempting to send anything other than 7-bit ASCII in email often resulted in data corruption. PBM was designed to allow images to be sent via email without being corrupted. Poskanzer released the forerunner of Netpbm, called Pbmplus in 1988. By the end of 1988, Poskanzer had developed the PGM (greyscale) and PPM (color) formats and released them with Pbmplus.

The last release of Pbmplus was on December 10, 1991. Poskanzer never released any further updates, and in 1993 Netpbm was developed to replace it. At first it was nothing more than a renamed release of Pbmplus, but updates continued to occur until 1995 when the package again became abandoned. In 1999 the Netpbm package was picked up by its present maintainer, Bryan Henderson.

In 2000, PAM was added to the file formats of the Netpbm library allowing an alpha channel.[2] The name Netpbm came from the program developers collaborating over the Internet, which was notable at the time. (The NetBSD operating system and Nethack game got their names similarly.)

PAM graphics format[edit]

Portable Arbitrary Map
Filename extension .pam
Internet media type image/x-portable-arbitrarymap[3]
Developed by Bryan Henderson
Type of format Image file formats
Extended from Portable aNy Map (PNM)
Open format? yes

Portable Arbitrary Map (PAM) is an extension of the older binary P4…P6 graphics formats. PAM generalises all features of PBM, PGM and PPM, and provides for extensions. PAM defines two new attributes; depth and tuple type:

  1. The depth attribute defines the number of channels in the image, such as 1 for greyscale images and 3 for RGB images.
  2. The tuple type attribute specifies what kind of image the PAM file represents, thus enabling it to stand for the older Netpbm formats, as well as to be extended to new uses, e.g., transparency.

As of 2014 PAM is not widely accepted or produced by graphics systems; e.g., XnView doesn't know it, but FFmpeg does.[4] As specified the TUPLTYPE is optional; however, FFmpeg requires it.

Differences from the older formats[edit]

The header for the PAM file format begins with P7, and (unlike in the other formats) ends in an explicit close: ENDHDR. Line ends in a PAM header are significant; for PNM line ends are white space.

There is no plain (human-readable, ASCII-based) version of PAM. PAM files are always binary, and attempts to use the switch -plain with Netpbm programs that produce PAM output results in an error message.

For the black-and-white version of PAM (depth 1, tuple type BLACKANDWHITE), corresponding to PBM, PAM uses one byte per pixel, instead of PBM’s use of one bit per pixel (packing eight pixels in one byte). Also, the value 1 in such a PAM image stands for white (“light on”), as opposed to black in PBM (“ink on”).

PAM tuple types
GRAYSCALE 2…65535 1 2 bytes per pixel for MAXVAL > 255
RGB 1…65535 3 6 bytes per pixel for MAXVAL > 255
BLACKANDWHITE_ALPHA 1 2 2 bytes per pixel
GRAYSCALE_ALPHA 2…65535 2 4 bytes per pixel for MAXVAL > 255
RGB_ALPHA 1…65535 4 8 bytes per pixel for MAXVAL > 255


All of the basic tuple types (BLACKANDWHITE, GRAYSCALE, and RGB) have a variant with an opacity channel. The tuple type is created by appending "_ALPHA" as a suffix to the base tuple type.

For example, an image with a tuple type of GRAYSCALE is equivalent to PGM (portable graymap). GRAYSCALE_ALPHA with transparency isn't directly possible in PGM. The specification permits MAXVAL 1 for GRAYSCALE, but it would have the same effect as BLACKANDWHITE.

An example in the BMP article shows an RGBA image with 4×2=8 blue, green, red, and white pixels; half transparent (0x7F) in the first lower row, opaque (0xFF) in the second upper row; hex. FF00007F 00FF007F 0000FF7F FFFFFF7F FF0000FF 00FF00FF 0000FFFF FFFFFFFF in BGRA order. For PAM this bitmap has to be given in RGBA order, swapping the 1st and 3rd byte in each pixel. BMP rows are typically arranged bottom-up, for PAM and PNM rows are given top-down, i.e. for this example 0000FFFF 00FF00FF FF0000FF FFFFFFFF 0000FF7F 00FF007F FF00007F FFFFFF7F. The PAM header for this example could be:

Bmp format2.svg 0,0: blue 0000FF FF 0,1: green 00FF00 FF 0,2: red FF0000 FF 0,3: white FFFFFF FF 1,0: blue 0000FF 7F, half transparent 1,1: green 00FF00 7F, half transparent 1,2: red FF0000 7F, half transparent 1,3: white FFFFFF 7F, half transparent
About this image


PAM's tuple-type mechanism allows for many extensions. In theory, PAM can be extended to represent colour models such as CMYK.

The format is not even limited to graphics, its definition allowing it to be used for arbitrary three-dimensional matrices of unsigned integers. Some programs of the Netpbm package, for example pamsummcol, function as crude matrix arithmetic processors and use the PAM format this way.

See also[edit]


  1. ^ Jeff Dairiki. "Online X-Face Converter". Retrieved 2014-03-02. 
  2. ^
  3. ^ MIME type not registered at IANA: PAM format specification
  4. ^ "Image Formats". FFmpeg General Documentation. 2014. Retrieved 2014-02-23.