|This article needs additional citations for verification. (February 2014)|
|Stable release||10.35.95 / 26 September 2014|
|Written in||C, Perl, Unix Shell|
|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
Netpbm defines a set of graphics formats called the Netpbm formats:
- The Portable Bit/Grey/PixMap formats PBM, PGM, PPM. They are collectively referred to as PNM (Portable aNy Map).
- The more sophisticated PAM (Portable Arbitrary Map) format.
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.
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. 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
|Internet media type||
|Developed by||Bryan Henderson|
|Type of format||Image file formats|
|Extended from||Portable aNy Map (PNM)|
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:
- The depth attribute defines the number of channels in the image, such as 1 for greyscale images and 3 for RGB images.
- 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.
Differences from the older formats
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”).
|BLACKANDWHITE||1||1||special case of GRAYSCALE|
|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:
P7 WIDTH 4 HEIGHT 2 DEPTH 4 MAXVAL 255 TUPLTYPE RGB_ALPHA ENDHDR
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.
|Wikimedia Commons has media related to Created with Netpbm.|
- Jeff Dairiki. "Online X-Face Converter". Retrieved 2014-03-02.
- MIME type not registered at IANA: PAM format specification
- Pierre-Emmanuel Gougelet (2015-02-19). "XnView 2.30". XnView. Retrieved 2015-02-20.
PAM format added
- "Image Formats". FFmpeg General Documentation. 2014. Retrieved 2014-02-23.