Free webp to jpg
PNM

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.

Raster Graphics Production Ready

Technical Specifications

MIME Type
image/x-portable-anymap
Extensions
.pnm
Container
Netpbm
Compression
Uncompressed
Algorithms
None
Color Depth
1-bit (PBM), 8-bit to 16-bit (PGM), 24-bit to 48-bit (PPM)
Metadata
None
Capabilities
Transparency
Animation
Progressive Loading
Alpha Channel
HDR Support
Official Specification
Aliases: image/pnmimage/x-pnm

Magic Bytes & HTTP Headers

File Signature (Magic Bytes)
50 31, 50 32, 50 33, 50 34, 50 35, or 50 36
ASCII: P1, P2, P3, P4, P5, P6
HTTP Headers
Content-Type: image/x-portable-anymap
Content-Type: image/pnm
HTML Accept Attribute
accept="image/x-portable-anymap, .pnm"

Browser Support Matrix

Browser Status Min Version
Chrome Chrome
Not Supported
Firefox Firefox
Not Supported
Safari Safari
Not Supported
Edge Edge
Not Supported
Internet Explorer Internet Explorer
Not Supported Legacy

Advantages & Limitations

Advantages
  • 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)
Limitations
  • 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

import magic
# Libmagic will typically resolve PNM files specifically to their sub-format (e.g., 'image/x-portable-pixmap' for P3/P6)
print(magic.from_file('image.pnm', mime=True))
const fs = require('fs');
// Manually checking the PNM magic bytes (P1 through P6)
const buffer = Buffer.alloc(2);
const fd = fs.openSync('image.pnm', 'r');
fs.readSync(fd, buffer, 0, 2, 0);
fs.closeSync(fd);
const isPNM = buffer[0] === 0x50 && buffer[1] >= 0x31 && buffer[1] <= 0x36;
console.log('Is Portable Anymap (PNM):', isPNM);
import (
    "bytes"
    "net/http"
)
// Native Go HTTP detection might not map specifically to the 'anymap' umbrella.
// Check directly for the P1-P6 signatures:
// isPNM := len(buf) >= 2 && buf[0] == 'P' && buf[1] >= '1' && buf[1] <= '6'
$mime = mime_content_type('image.pnm');
echo $mime; // Standard PHP setups will likely return the specific sub-type like 'image/x-portable-pixmap'

File Detection Steps

How to programmatically detect a image/x-portable-anymap file by reading its raw bytes:

  1. 1 A PNM file always begins with a 2-byte magic number starting with 'P' (Hex: 50).
  2. 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. 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

N
Netpbm (Command-line tools)
ImageMagick ImageMagick
GIMP GIMP
X
XnView

Conversion Tools

Share & Embed

Markdown Badge
PNM Format Badge
[![PNM Format](https://freewebptojpg.com/mime/image/pnm/badge.svg)](https://freewebptojpg.com/mime/image/pnm)
Interactive iframe Widget
<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
Free to use
No auth required
CORS enabled
Use from any domain
Cached 24h
Cache-Control headers set

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.

Related Formats

Share this format