Skip to content
Morphr

Image format · .pnm

What is a PNM file?

PNM is the Portable Anymap family — PBM for bitmaps, PGM for greyscale and PPM for colour — a set of deliberately bare-bones, uncompressed image formats from the Netpbm project. Devised by Jef Poskanzer in the 1980s, they are prized in Unix pipelines and academia for being almost insultingly easy to parse.

Full name
Portable Anymap (PPM/PGM/PBM)
Category
Image
File extension
.pnm, .ppm, .pgm, .pbm
MIME type
image/x-portable-anymap
Developer
Jef Poskanzer (Netpbm)
First released
1980s
Compression
None
Standard
Open (de facto)
Transparency
No

Three formats, one philosophy

The family shares a common structure: a two-character magic number identifies the type, followed by the width, height and (for greyscale and colour) the maximum sample value, then the pixel data itself. PBM stores one bit per pixel for pure black and white, PGM stores a single grey value per pixel, and PPM stores red, green and blue triples. Each comes in an ASCII variant, where every number is written out as plain text, and a more compact binary variant. There is no compression and no metadata to speak of — the file is essentially a header followed by raw samples.

That austerity is the whole appeal. You can write a working PPM reader in a handful of lines, and you can generate one from a shell script or a few printf statements, which makes the format a natural lingua franca between command-line image tools.

A glue format for pipelines

Netpbm grew up as a toolbox of small programs that each do one transformation and pass images along through pipes, with PNM as the connecting tissue. Researchers and educators still reach for it when they want to manipulate pixels directly without wrestling a real codec, and many converters use PPM as a simple intermediate. It is a means to an end, not a format you would ever ship to a user.

Strengths

  • Trivially simple to read, write and generate — even from a script.
  • Uncompressed and lossless, so pixel values are exact.
  • A reliable common intermediate between command-line image tools.

Limitations

  • No compression, so files are large.
  • No alpha channel and essentially no metadata.
  • Unsuitable for distribution or display to end users.

When to use PNM

Reach for PNM as a scratch or intermediate format in scripts, pipelines and teaching, where you want to touch raw pixels without the overhead of a real codec.

PNM FAQ

What is the difference between PBM, PGM and PPM?
PBM stores one-bit black-and-white images, PGM stores greyscale with one value per pixel, and PPM stores full colour as red-green-blue triples. They share the same simple header style, and PNM is the umbrella term covering all three.
Why would anyone use an uncompressed image format?
Because simplicity beats size in some contexts. PNM is ideal when you are writing or debugging image code, chaining command-line tools, or teaching, since there is no codec to get in the way of the raw pixels.
How do I convert a PPM to PNG?
Any tool that understands the Netpbm family can re-encode it; Morphr will read the PPM and write a compressed PNG or JPEG in the browser. That gives you a far smaller, widely supported file without losing detail when you choose PNG.