PBM, PGM & PPM — The Netpbm Family
Dead-simple, uncompressed raster formats built for image-processing pipelines.
Last updated: June 26, 2026
PBM, PGM, and PPM are a family of deliberately minimal raster image formats from the Netpbm toolkit, collectively known as PNM (Portable Anymap). PBM stores 1-bit black-and-white bitmaps, PGM stores grayscale, and PPM stores full RGB color. Each can be written as human-readable ASCII text or compact binary, and all of them are uncompressed and trivially easy to parse. Their simplicity has made them an enduring lingua franca for image-processing tools, scientific computing, and Unix utilities. Snap2Format reads and writes these formats alongside more common ones.
What is PBM?
PBM is the simplest member of the Netpbm family of formats, which also includes PGM and PPM. The three are designed as a graduated set: PBM (Portable Bitmap) holds 1-bit images where each pixel is purely black or white; PGM (Portable Graymap) holds grayscale images with a range of intensity values; and PPM (Portable Pixmap) holds full-color RGB images. The umbrella term PNM (Portable Anymap) refers to any of them.
What unites the family is a philosophy of extreme simplicity. The files have no compression and almost no structure beyond a short text header followed by raw pixel values. This makes them larger than compressed formats but exceptionally easy to read and write — a programmer can parse or generate one with a few lines of code and no special library. That transparency, rather than efficiency, is the whole point, which is why the family has survived for decades as a universal intermediate format.
The History of PBM
The Netpbm formats were created by Jef Poskanzer in the late 1980s as part of a toolkit originally called Pbmplus. The goal was practical: in an era of many incompatible image formats and platforms, Poskanzer needed a simple common denominator that any program could read and write, so that a chain of small Unix tools could pass images between one another without friction.
PBM came first for black-and-white bitmaps, soon joined by PGM for grayscale and PPM for color, with PNM serving as the collective name. The toolkit evolved into the widely distributed Netpbm package, a large collection of command-line utilities that convert dozens of formats to and from these portable types. Because the formats are so easy to support, they were quickly adopted across academic, scientific, and open-source software, and they remain a dependable building block in image-processing workflows today.
How PBM Works
Every file in the family begins with a two-character magic number that identifies both the type and the encoding. The magic number is followed by the image dimensions, a maximum color value where relevant, and then the pixel data. Each format comes in two flavors:
- ASCII (plain) encoding — magic numbers P1, P2, and P3 — stores every pixel as readable decimal text, so the file can be opened and edited in a normal text editor.
- Binary (raw) encoding — magic numbers P4, P5, and P6 — stores pixels as compact bytes, producing much smaller files that are faster to read.
In PBM each pixel is a single bit, in PGM each pixel is a gray value up to a stated maximum, and in PPM each pixel is a triple of red, green, and blue values. There is no compression at any stage, so the file size is essentially proportional to the pixel count. This direct, predictable layout is exactly what makes the formats so easy to generate and consume programmatically.
Key Features of PBM
The Netpbm formats trade efficiency for clarity, and their feature set reflects that focus:
- Extreme simplicity — a short header and raw pixel values, parseable in a handful of lines of code.
- Human-readable option — the ASCII variants let you inspect and even hand-edit pixel data in a text editor.
- Three tiers of color depth — 1-bit bitmaps (PBM), grayscale (PGM), and RGB color (PPM) under one consistent design.
- No compression, so encoding and decoding involve no complex algorithms and never lose data.
- Platform independence — the formats behave identically across operating systems and architectures.
- Wide tool support in the Netpbm utilities and most image libraries.
The obvious cost of this design is file size: an uncompressed PPM is far larger than an equivalent PNG or JPEG. The formats are therefore best understood as working or intermediate formats rather than as a way to store or distribute finished images.
Common Use Cases
The Netpbm family thrives wherever simplicity and easy parsing matter more than compact storage. Typical roles include:
- Intermediate format in pipelines, where a chain of command-line tools converts and processes images one step at a time.
- Scientific and academic computing, in which researchers generate or analyze raw pixel data without wrestling with complex codecs.
- Unix and open-source tooling, where the Netpbm utilities glue together many different format converters.
- Programming and education, since writing a basic PPM is a classic exercise for learning how raster images work.
- Debugging and prototyping, where dumping pixels to a readable file makes problems easy to inspect.
For final delivery — websites, photo libraries, or sharing — these formats are rarely the right choice because of their size. The usual pattern is to compute or manipulate images as PNM and then convert the result to a compressed format like PNG or JPEG for storage and distribution.
PBM vs Other Image Formats
The defining contrast is compression. Formats like PNG and JPEG apply sophisticated algorithms to shrink files dramatically — PNG losslessly, JPEG by discarding detail — at the cost of more complex encoders and decoders. The Netpbm formats do the opposite: they store pixels raw, so files are large but the code to read and write them is almost trivial. A color PPM of a photograph can be several times the size of the same image saved as PNG.
Within the family itself, the choice is about color depth: PBM for pure black-and-white, PGM for grayscale, and PPM for full color, each in an ASCII or binary variant. Compared with formats like BMP, which is also largely uncompressed, PNM is simpler and more text-friendly. The practical guidance is clear: use PNM as a convenient, transparent working format, and convert to a compressed format whenever size or compatibility becomes important.
Tips for Working with PBM
A few practices make the Netpbm formats more pleasant to use:
- Prefer the binary variants (P4, P5, P6) for real data, since they are far smaller and faster than the ASCII forms while holding the same pixels.
- Use ASCII variants (P1, P2, P3) when you want to inspect or hand-edit values for debugging or teaching.
- Pick the right tier — do not store a black-and-white scan as a full-color PPM when a PBM would be a fraction of the size.
- Convert for delivery by exporting to PNG or JPEG before sharing, archiving, or putting images on the web.
- Watch the maximum value in PGM and PPM headers, as it defines how the pixel numbers map to actual intensities.
Treated as a clean intermediate format and converted when finished, the PNM family remains a reliable, fuss-free part of any image workflow.
PBM at a Glance
| Full name | Portable Bitmap / Graymap / Pixmap (Netpbm PNM family) |
| File extension | .pbm, .pgm, .ppm, .pnm |
| Developed by / Year | Jef Poskanzer (Netpbm/Pbmplus), late 1980s |
| Compression | None (uncompressed) |
| Transparency | No |
| Color support | 1-bit (PBM), grayscale (PGM), RGB color (PPM) |
| Best for | Intermediate format in image-processing and scientific pipelines |
Advantages of PBM
- Extremely simple to read and write
- Optional human-readable ASCII encoding
- Lossless and platform independent
- Widely supported across image-processing tools
Limitations of PBM
- Uncompressed, so files are very large
- No transparency or metadata support
- Poor choice for web delivery or sharing
Convert PBM Files
Upload your PBM file to the Snap2Format converter, choose your output format (JPG, PNG, WebP, PDF and more), and download the result in seconds — free, with no signup.
PBM — Frequently Asked Questions
PBM stores 1-bit black-and-white images, PGM stores grayscale, and PPM stores full RGB color. PNM is the umbrella name covering all three formats.
They are magic numbers identifying the format and encoding. P1, P2, and P3 are ASCII PBM, PGM, and PPM, while P4, P5, and P6 are their compact binary equivalents.
No. The entire Netpbm family is uncompressed, which keeps the formats simple to parse but results in much larger files than PNG or JPEG.
They are ideal as an intermediate format in image-processing pipelines, scientific computing, and Unix tooling, where easy parsing matters more than small file size.
Yes. Because these formats are uncompressed and finished images are usually large, converting them to PNG or JPEG is the standard way to store or share the result.
Explore Other Image Formats
Learn about the formats most often used alongside PBM: