.ppm.pgm.pbm.pnm.pam
PPM, PGM and PBM files: what they are and how to open them
PPM, PGM and PBM files are uncompressed color, grayscale and black and white images from the Netpbm family: a short text header followed by raw pixel values. Open them free in GIMP or IrfanView, or in Universal File Opener on Android or Windows.
Drop your Netpbm file here
Opens on this device. Nothing is uploaded. Any other file works too.
What is a Netpbm file?
PPM (portable pixmap) holds color, PGM (portable graymap) grayscale and PBM (portable bitmap) black and white. PNM is the umbrella name for the three, and PAM, added in 2000, generalizes them to any number of channels, including transparency. You meet them in image processing, computer vision and scientific software, and as the in-between format of command-line image converters.
Jef Poskanzer created PBM in the 1980s as a trouble-free bitmap format that could travel inside a plain text email. By the end of 1988 he had added PGM and PPM to Pbmplus, his conversion toolkit. Netpbm replaced it in 1993 and is still maintained; its manual is the specification. The formats are deliberately simple, so a program that reads and writes them reaches every other format through Netpbm’s converters.
Two facts explain most problems: there is no compression, so a 12-megapixel color photo takes about 36 MB as a PPM, and few everyday apps read the formats at all. Windows has no built-in decoder for them.
What is inside
Every file starts with a magic number that names the variant: P1, P2 and P3 for plain text PBM, PGM and PPM, P4, P5 and P6 for their binary forms, and P7 for PAM. Then come the width, the height and, except for PBM, the maxval, the brightest possible sample, as decimal text. PAM uses named lines instead (WIDTH, HEIGHT, DEPTH, MAXVAL) ending with ENDHDR.
The pixels follow, top row first. A binary PPM stores red, green and blue for each pixel, 1 byte per sample when the maxval is under 256 and 2 bytes up to 65535; a binary PBM packs 8 pixels into each byte, with 1 meaning black. Plain files write every sample as a decimal number, so a text editor can read them.
photo.ppmP6binary color (P3 is the plain text form)# a commentoptional640 480width and height255maxval: 1 byte per samplepixel data640 × 480 × 3 = 921,600 bytes, top row firstHow to open a Netpbm file
Windows
- IrfanViewFree for non-commercial use. Opens and saves PBM, PGM and PPM.
- GIMPFree. Opens plain and binary PBM, PGM, PPM and PAM, including 16-bit files, and exports them.
- Universal File Opener for WindowsOursOpens PBM, PGM, PPM, PNM and PAM images and saves a PNG, JPEG or BMP copy.
Mac
- GIMPFree. Opens and exports every Netpbm variant, plain or binary, including PAM.
iPhone and iPad
- HDRView in SafariFree web app that runs on iPhone and iPad. Shows binary PGM and PPM files; not PBM or the plain text forms.
Android
- Universal File OpenerOursOpens plain and binary files, edits them and saves back as PPM, PGM, PBM or PAM with transparency, or converts to PNG or JPEG.
In a browser
- HDRViewFree. Its web version shows binary PGM and PPM files, with pixel values on zoom.
Won’t open?
Double-clicking does nothing on Windows
Windows has no decoder for Netpbm images, so Photos and File Explorer cannot show them. Install GIMP or IrfanView, or open the file in Universal File Opener for Windows.
It opens as a page of numbers
That is a plain file (P1, P2 or P3): the pixels are written as decimal text, so a text editor shows numbers. Open it in an image app instead; GIMP reads the plain forms.
An app rejects a 16-bit or PAM file
A maxval above 255 means 2 bytes per sample, and PAM (P7) arrived in 2000, so older readers accept neither. GIMP opens both; export from it as PNG, which also keeps 16 bits per sample.
The file is far too big to share
Netpbm has no compression. Convert a copy to PNG, which is lossless and usually much smaller, and keep the original only if a tool needs it.
Convert a Netpbm file
- To PNG, in GIMPOpen the file, choose File, Export As, type a name ending in .png and click Export. The pixels stay exactly the same.
- To PNG or JPEG, on AndroidOpen the file in Universal File Opener, tap Edit, choose Convert to and pick PNG or JPEG.
- To PNG, on the command lineWith Netpbm installed, run pnmtopng photo.ppm > photo.png. pngtopam and jpegtopnm go the other way.
Netpbm files in our apps
Universal File Opener opens plain and binary PBM, PGM, PPM, PNM and PAM images on Android and Windows. On Android, edit and save back in the same format, keeping PAM transparency, or convert a copy to PNG or JPEG.
All Android tools and limits for Netpbm files
- View supported ASCII and binary Netpbm images.
- Edit and save back: P6/P5/P4 for the classic formats, P7 PAM preserving RGBA.
- Convert to PNG or JPEG, or create PPM, PGM or PBM output from a supported image.
Limits
- Netpbm files are uncompressed and can be large. A PNG copy can reduce storage requirements.
Walkthrough: Edit and convert images on Android