Portable Anymap
image/x-portable-anymap
Released 1988
· by Jef Poskanzer (Netpbm Project)
The image/x-portable-anymap MIME type represents the Portable Anymap (PNM) format, part of the Netpbm project. PNM is not a distinct format itself, but rather a collective umbrella designation that encompasses three foundational raster formats: Portable Bitmap (PBM for 1-bit monochrome), Portable Graymap (PGM for grayscale), and Portable Pixmap (PPM for RGB color). Developed in the late 1980s by Jef Poskanzer, these formats were designed with absolute simplicity in mind, acting as a lowest-common-denominator intermediary to facilitate easy image exchange between disparate platforms and command-line pipelines in Unix environments. A PNM file contains a simple magic number (P1 through P6) indicating its specific sub-format and whether the data is stored as human-readable ASCII text or raw binary.
Technical Specifications
.pnm
None
image/pnmimage/x-pnm
Magic Bytes & HTTP Headers
P1, P2, P3, P4, P5, P6
Browser Support Matrix
| Browser | Status | Min Version |
|---|---|---|
|
|
Not Supported | — |
|
|
Not Supported | — |
|
|
Not Supported | — |
|
|
Not Supported | — |
|
|
Not Supported | Legacy |
Advantages & Limitations
- Unparalleled simplicity: parsers and writers for PNM files can be written from scratch in C or Python in just a few minutes without relying on external libraries
- Serves as an excellent foundational teaching tool for computer science students learning about image arrays and raster graphics
- Flawlessly pipes through Unix command-line utilities for robust automated image processing (via the Netpbm suite)
- Zero compression natively results in astronomical file sizes, making it entirely impractical for web delivery or consumer storage
- No support for standard metadata formats like EXIF, XMP, or ICC color profiles
- No native alpha channel support in the classic PNM specification (though the newer PAM format 'P7' addresses this)
Developer Code Snippets
File Detection Steps
How to programmatically detect a image/x-portable-anymap
file by reading its raw bytes:
- 1 A PNM file always begins with a 2-byte magic number starting with 'P' (Hex: 50).
- 2 The second byte determines the exact sub-format: '1' or '4' for PBM (bitmap), '2' or '5' for PGM (graymap), and '3' or '6' for PPM (pixmap).
- 3 Following the magic bytes are whitespace-separated ASCII representations of the image's width and height. Lines beginning with '#' are comments and should be ignored by parsers.
Software Support
ImageMagick
Conversion Tools
Share & Embed
[](https://freewebptojpg.com/mime/image/pnm)
<iframe src="https://freewebptojpg.com/mime/image/pnm/embed" width="100%" height="280" style="border:1px solid #cbd5e1;border-radius:8px;" title="PNM Specs"></iframe>
JSON API
All data on this page is available as a free, open JSON API. Use it in your project, documentation, or tooling.
GET https://freewebptojpg.com/mime/image/pnm.json
Open JSON
Frequently Asked Questions
What is a PNM file?
A PNM (Portable Anymap) file is a collective extension used for the Netpbm family of image formats. It can internally act as a PBM (black and white), PGM (grayscale), or PPM (color) image.
Can I open a PNM file in a text editor?
Yes, if the PNM file was saved using the 'plain' (ASCII) encoding (magic numbers P1, P2, or P3), you can open it in any text editor and see the actual pixel values written out as readable numbers.
Are PNM files compressed?
No. The Netpbm family of formats relies on completely uncompressed pixel data. This makes them incredibly easy to read and write programmatically, but results in massive file sizes compared to modern formats like PNG or JPEG.