PGM
Generated by scripts/gen-format-pages.py from docs/data/format-metadata/, FILE_FORMATS.csv and docs/formats-master.csv. Do not edit by hand: change the source, then run the script.
Netpbm Grayscale (PGM) Preview.
At a glance
| Original creator | Jef Poskanzer, in Pbmplus; now part of Netpbm |
| First published | 1988 |
| Purpose | Portable graymap: a minimal greyscale image with a short text header, in plain-text or binary samples. |
| Extensions | .pgm |
| Poka parser | poka-pgm |
| Viewer | poka-image-with-meta-viewer |
| Depth tier | Parser with a shared viewer (see Depth tiers) |
| Breadth tier | B1 Complete (see Breadth tiers) |
How much Poka reads
B1 Complete. Everything the format defines that a reader would see is decoded, in every version Poka claims. Anything not decoded is immaterial and listed.
Confidence: high (the reviewer read the code and a test that proves the claim). Basis: Reviewed 2026-10-16: parsers/poka-pgm/src/lib.rs (own header parse for the panel, image 0.25.10 pnm decoder for pixels), unit tests, and corpus files 16_bit_binary.pgm (P5, maxval 65535) and testPGM.pgm (P2) which render in tests/samples.rs. Covers P2 and P5, 8- and 16-bit, with header comments shown. Pixels over a 192 MiB budget (about 10000 x 10000) are reported, not drawn.
What Poka does not read
- only the first image of a multi-image P5 stream
- a .pgm file whose content is P1, P3, P4, P6 or PFM is refused (poka-ppm reads those only under .ppm, .pbm and .pam)
Background
Wikipedia says that by the end of 1988 Poskanzer had added the PGM and PPM formats to Pbmplus, after PBM, and that Netpbm replaced Pbmplus in 1993. Poka reads the header itself and decodes the samples with the image crate, then shows a PNG.
Versions
| Version | Identifier | Poka | Note |
|---|---|---|---|
| Plain PGM | P2 |
Read | |
| Raw PGM, 8- and 16-bit samples | P5 |
Read |
Libraries
Libraries Poka uses or has assessed for this format, with the status, licence and language the registry records.
- image (used; MIT OR Apache-2.0; Rust)
- png (used; MIT OR Apache-2.0; Rust)
- oxideav-pbm (candidate; MIT; Rust; https://github.com/OxideAV/oxideav-pbm) — could replace about 2,000 lines of Netpbm parsers
Sources
- https://en.wikipedia.org/wiki/Netpbm
- parsers/poka-pgm/src/lib.rs