.PNM

PNM File

Portable Anymap
Ask a question
QUICK ANSWER

A PNM file is a Portable Anymap - a simple, uncompressed raster image covering three sub-formats: PBM (black & white), PGM (grayscale), and PPM (color). Open it with GIMP, IrfanView, or XnView on any platform. For everyday storage, convert to PNG (lossless) or JPEG using ImageMagick or any of those tools.

Developer: Jef Poskanzer (original PBM/PGM/PPM, 1988); Netpbm maintained by Bryan Henderson and community Category: Raster Image Files Open standard MIME: image/x-portable-anymap
OPENS ON Windows macOS Linux Web
Related: .JPG · .PNG · .TIF · .ECW

On this page

19k+ extensions indexed
Last reviewed Aug 21, 2026

Not sure what your file is?

Drop any file into our identifier - we read just the first bytes to name the format.

Identify a file

What is the PNM file format?

.pnm (Portable Anymap) is an umbrella extension covering three related uncompressed raster image sub-formats from the Netpbm family: PBM (Portable Bitmap, 1-bit black-and-white), PGM (Portable Graymap, greyscale), and PPM (Portable Pixmap, colour). The actual sub-type of any .pnm file is identified by its first two bytes: P1-P3 for the ASCII ("plain") variants and P4-P6 for the binary ("raw") variants.

Jef Poskanzer created the original PBM format in 1988 as part of his Pbmplus toolkit, adding PGM and PPM shortly after. The formats were designed to be the simplest possible lossless image representation, capable of surviving transit over 7-bit email links. The ASCII variants store pixel values as whitespace-separated decimal integers after a plain-text header; the binary variants pack raw bytes immediately after the header for more compact storage.

Color depth ranges from 1 bpp (PBM) to 16 bpp per channel (PGM/PPM with 16-bit maxval), yielding up to 48 bpp for colour images. The format defines no compression, encryption, colour profile, EXIF data, or thumbnails - it is deliberately minimal.

PNG is the modern replacement for lossless storage, but .pnm files remain a ubiquitous intermediate format in Unix image-processing pipelines. ImageMagick, GIMP, FFmpeg, and virtually all Unix image tools read and write the format natively.

Security & safety

RISK: LOW

PNM/PBM/PGM/PPM are among the simplest image formats - plain text header plus raw pixel data (or ASCII values). No code execution, no scripting, no compression exploits. Very safe to open. The main risk is the trivially large uncompressed file size for high- resolution images.

Format details

in a nutshell
FULL NAMEPortable Anymapaka Netpbm anymap, PNM image
DEVELOPERJef Poskanzer (original PBM/PGM/PPM, 1988); Netpbm maintained by Bryan Henderson and communitysince 1988 (Jef Poskanzer's Pbmplus toolkit; PBM first, PGM and PPM by year-end)
MIME TYPEimage/x-portable-anymap
TYPESimple uncompressed raster image (text or binary encoding); umbrella extension for PBM/PGM/PPM
STANDARDOpen · royalty-free
MAGIC BYTES · FILE SIGNATURE
OFFSET
0001
HEX
5031
ASCII
P1
First 2 bytes are always 'P' (0x50) followed by a digit 1-6 (0x31-0x36): P1=PBM ASCII, P2=PGM ASCII, P3=PPM ASCII, P4=PBM binary, P5=PGM binary, P6=PPM binary. P7=PAM (Portable Arbitrary Map) uses extension .pam. .pnm is the generic extension that may contain any of P1-P6.

Programs that open PNM files

Windows5 apps
ImageMagick Open-source Command-line: 'magick display file.pnm' or 'magick file.pnm output.jpg' to convert.
XnView Free Open directly or drag and drop. Supports PBM/PGM/PPM/PNM.
GIMP Open-source File > Open. GIMP reads all Netpbm variants natively.
IrfanView Free File > Open; select the .pnm file. Also supports batch conversion.
FastPictureViewer Professional Paid Opens PNM files for fast browsing in a photo-review workflow.
macOS3 apps
GIMP Open-source File > Open. Full Netpbm support.
ImageMagick Open-source Install via Homebrew ('brew install imagemagick'); use 'magick file.pnm output.png'.
XnView MP Free File > Open. XnView MP is the cross-platform successor to XnView.
Linux4 apps
GIMP Open-source File > Open. Native Netpbm support in all Linux distributions.
ImageMagick Open-source Package in all major distros ('apt install imagemagick'). Canonical PNM tool on Linux.
XnView MP Free Cross-platform GUI viewer with full PNM support.
display (ImageMagick) Open-source Shell: 'display file.pnm' to view interactively on any X11 desktop.
Web1 app
Convertio Freemium Upload PNM file; convert to JPG, PNG, PDF, etc. online.

Technical details

deep spec
Sub-formatsUmbrella for PBM (P1/P4, 1-bit), PGM (P2/P5, greyscale), and PPM (P3/P6, colour)
Magic bytesFirst 2 bytes: `P` (0x50) + digit `1`-`6` (0x31-0x36) - identifies sub-type and ASCII vs. binary encoding
ASCII variants (P1-P3)Pixel values stored as whitespace-separated decimal integers - human-readable and 7-bit safe
Binary variants (P4-P6)Raw pixel bytes packed immediately after the ASCII header - more compact, same logical data
CompressionNone - pixel data stored uncompressed in all variants
Color depth1 bpp (PBM); 8 or 16 bpp per channel greyscale (PGM); 24 or 48 bpp colour (PPM with 16-bit maxval)
Header structureASCII fields: magic number, optional `#` comment lines, width, height, then maxval (absent for P1/P4 1-bit)
Byte orderBig-endian for 16-bit samples in binary P5/P6 variants; not applicable for 8-bit or ASCII formats
Maxval constraintMust be 1-65,535 (uint16); values ≤ 255 use 1 byte per sample in binary P4-P6 modes
DimensionsNo defined maximum; limited in practice by available system memory
MIME type`image/x-portable-anymap`; sub-types: `image/x-portable-bitmap`, `image/x-portable-graymap`, `image/x-portable-pixmap`
PAM extensionP7 (`.pam`, Portable Arbitrary Map) extends PNM to arbitrary channel counts and bit depths
Typical useUnix image-processing pipeline intermediate format; native I/O for ImageMagick, GIMP, FFmpeg, and most Unix image tools
Released1988 (Jef Poskanzer's Pbmplus toolkit; PBM first, PGM and PPM by year-end)
Latest versionNetpbm 11.x (2020s); format spec stable since early 1990s
Open standardYes · royalty-free
Specificationnetpbm.sourceforge.net

PNM conversions

Community Q&A

asked by users
Ask a quick question
Get help from people who work with PNM files. Be specific - include your system and software version.
No account needed · answers usually within a day

No questions yet - be the first to ask about PNM files.

Frequently asked questions

What is the difference between PNM, PBM, PGM, and PPM?
PNM (Portable Anymap) is the umbrella name for the family. PBM (Portable Bitmap) is 1-bit black & white. PGM (Portable Graymap) is grayscale (8 or 16 bpp). PPM (Portable Pixmap) is full color (24 or 48 bpp). A .pnm file is always one of these three; the magic number (P1-P6) inside tells you which.
How do I convert a PNM file to JPEG or PNG?
Use ImageMagick: 'magick input.pnm output.jpg' or 'magick input.pnm output.png'. IrfanView and XnView also do this through the GUI. PNG is preferred for lossless conversion.
Why is my PNM file so large?
PNM stores completely uncompressed pixel data - there's no compression at all. A 1920×1080 color image in binary PPM (P6) is about 6 MB; the ASCII PPM variant (P3) would be around 25 MB. Convert to PNG for lossless storage at a fraction of the size.
Can Photoshop open PNM files?
Adobe Photoshop does not support PNM natively. Use GIMP (free) or ImageMagick to open and convert the file, then open the converted PNG/BMP in Photoshop.
What is the magic number for a PNM file?
The first two bytes are always 'P' followed by a digit: P1 (PBM ASCII), P2 (PGM ASCII), P3 (PPM ASCII), P4 (PBM binary), P5 (PGM binary), P6 (PPM binary).

References

1Wikipedia - Netpbmen.wikipedia.org
2Netpbm - PNM format specificationnetpbm.sourceforge.net

Keep exploring

across the database

Top extensions this week

1.AQQAQQ Instant Messenger File
2.BINCD/DVD Disc Image (BIN/CUE)
3.MDMarkdown Document
4.PARTPartial Download File
5.RPMSGRestricted Permission Message
6.CRDOWNLOADChrome Partial Download File
7.NOMEDIAAndroid No-Media Marker File
8.PRDXSoftMaker Presentations Document
9.PRO6XProPresenter 6 Bundle File
10.SWFSmall Web Format (Shockwave Flash)

Related extensions

.JPGJPEG Image
.PNGPortable Network Graphics
.TIFTagged Image File Format
.ECWEnhanced Compression Wavelet (ECW) image
.AVIFAV1 Image File Format (AVIF)
.JP2JPEG 2000 Image (ISO/IEC 15444-1)

Free file tools

An in-browser file identifier and image converter - everything runs on your device.

Open the toolbox

Browse file extensions A-Z