What is PNM? Netpbm Portable Anymap Format Explained
The Netpbm family of simple, portable PBM, PGM and PPM image formats.
Last updated:
What is PNM?
PNM (Portable Anymap) is a collective name for a family of simple raster image formats from the Netpbm project: PBM (Portable Bitmap, 1-bit), PGM (Portable Graymap, grayscale) and PPM (Portable Pixmap, color). The formats originated with Jef Poskanzer's Pbmplus toolkit, released in 1988.
Each file begins with a two-character magic number: a capital P followed by a digit. P1, P2 and P3 are the human-readable 'plain' (ASCII) variants of PBM, PGM and PPM, while P4, P5 and P6 are the corresponding compact 'raw' (binary) variants. A small text header gives the dimensions and, for PGM/PPM, the maximum sample value. The related PAM format uses the magic number P7.
How PNM Works
PNM is an umbrella term for three Netpbm formats: PBM for 1-bit bitmaps, PGM for grayscale, and PPM for color.[1] Each file opens with a two-character magic number, a capital P followed by a digit, then a short text header giving the dimensions and, for PGM and PPM, the maximum sample value before the pixel data.[3]
History and Standardization
The family originated with Jef Poskanzer's Pbmplus toolkit, released in 1988, and was carried forward by the Netpbm project, whose documentation serves as the reference specification.[2] The deliberately minimal design made the formats ideal as a lingua franca between conversion tools.[1]
Plain vs Raw Variants
P1, P2, and P3 are the human-readable ASCII variants of PBM, PGM, and PPM, while P4, P5, and P6 are the compact binary equivalents that store samples as raw bytes.[1] The related PAM format, identified by magic number P7, generalizes the family with an extensible header and arbitrary channels.[1]
MKV Technical Specifications
PNM vs Other Image Formats
| Feature | PNM | PNG | BMP |
|---|---|---|---|
| Type | Raster | Raster | Raster |
| Scope | PBM/PGM/PPM family[1] | Single format | Single format |
| Compression | None[1] | Lossless | None or RLE |
| Transparency | No | Yes | Limited |
| Encoding | ASCII or binary[3] | Binary | Binary |
| Best for | Image-processing pipelines[2] | Web graphics | Windows images |
PNM is an umbrella for the simple Netpbm formats, prized as an easy intermediate in tooling rather than for compact storage like PNG.
Advantages & Disadvantages
Advantages
A tiny text header plus pixel data makes PNM formats trivial to read and write, ideal for quick tools and pipelines.
The formats were designed for easy exchange between platforms and are supported by virtually all image-processing toolkits.
ASCII variants are human-readable and easy to debug, while binary variants store the same data compactly.
PNM stores raw, uncompressed samples, so no image quality is lost when saving.
Disadvantages
PNM files are uncompressed, so they are much larger than formats like PNG for the same image.
The formats carry essentially no metadata beyond dimensions and maximum sample value.
PBM, PGM and PPM have no alpha channel; transparency requires the extended PAM format.
Common Use Cases
PNM formats are widely used as simple intermediates in image-processing and conversion pipelines.
Conversion intermediates | FileFormer
The Netpbm toolkit uses PNM as a common intermediate format when converting between many other image formats.
Programmatic image generation | FileFormer
Their simple structure makes PBM/PGM/PPM easy targets for scripts and programs that generate images directly.
Teaching and prototyping | FileFormer
The readable layout makes PNM popular for learning image formats and for quick prototyping of graphics code.
Convert PNM Files Free
Use our free online converter to convert PNM and other formats - no signup, no watermarks.
Try Image Converter FreeFrequently Asked Questions
What do PBM, PGM and PPM mean?
PBM is Portable Bitmap (1-bit), PGM is Portable Graymap (grayscale), and PPM is Portable Pixmap (color); PNM refers to them collectively.
What is the difference between plain and raw PNM?
Plain (ASCII) variants P1/P2/P3 store sample values as text, while raw (binary) variants P4/P5/P6 store the same data as compact bytes.
Does PNM support compression?
No. PNM formats store uncompressed pixel data, which keeps them simple but makes files large.
What is PAM?
PAM (Portable Arbitrary Map, magic number P7) is a Netpbm extension that generalizes PBM/PGM/PPM and adds features such as an alpha channel.
Who created the PNM formats?
They originated with Jef Poskanzer, whose Pbmplus toolkit (1988) was the forerunner of the Netpbm project.