Guide
Viewing and converting PPM, PGM, PBM and PAM files as PNG
The Netpbm formats are the simplest image files there are: a short text header followed by pixel values. That is why programming courses, computer graphics assignments, ray tracers, scientific tools and image processing libraries love to write them. The catch is that almost no ordinary viewer opens .ppm, .pgm or .pbm files. This converter shows and converts them to PNG or JPG directly in the browser.
The family of formats
PBM holds pure black-and-white bitmaps, PGM holds grayscale, and PPM holds color. Each comes in a plain variant, where pixel values are written as readable numbers (P1, P2, P3), and a binary variant (P4, P5, P6), which is much more compact. PAM (P7) is the later, more general form that can also carry an alpha channel. All of them are read here.
Bit depth and maxval
Every PGM, PPM and PAM header declares a maximum value, maxval. Values up to 255 use one byte per sample; larger values up to 65535 use two bytes, giving 16-bit precision. The converter accepts any maxval and scales the samples to the 0–255 range of standard PNG and JPG, so an image written with maxval 1, 15, 255 or 1023 always shows the full brightness range correctly.
Checking your program’s output
When you write a renderer or filter, the quickest test is to drop the output file here and look at it. Errors in your code tend to show up clearly: a shifted or slanted image usually means the row length is off by a few pixels, colors swapped between channels point to a wrong order of red, green and blue, and an image that is mostly noise often means extra bytes in a binary file. On Windows, binary output must be written in binary mode, or newline translation corrupts the data.
Error messages
If a file is truncated, if the header has a non-numeric value, or if a PAM header has an invalid depth, the converter says so specifically rather than producing a garbled picture. That makes it a handy validator as well as a viewer.
Choosing PNG or JPG
PNG is lossless and the natural choice: it keeps every pixel of your rendering exactly, and PAM transparency is preserved. JPG produces small files for sharing photographic renders, with a quality slider and a background color for any transparent areas.
Black-and-white bitmaps
PBM images contain only black and white pixels. In PBM, a 1 means black and a 0 means white, which surprises many people who expect the opposite. The converter follows the specification, so a correctly written file shows as intended.
Writing a valid file
A minimal color image is the text P3, then width and height, then the maxval 255, followed by three numbers per pixel, row by row from the top. Comments start with a hash sign and run to the end of the line. Binary P6 uses the same header, a single whitespace character after maxval, and raw bytes afterwards. If the converter accepts your file, other Netpbm readers will too.
Many files at once
Drop a series of frames from an animation or a batch of test outputs; each one converts separately and can be downloaded together. To animate a series afterwards, use the GIF Maker.
Related tools
For other uncompressed formats, see TGA to PNG and BMP to JPG. To compare two renders, the Image Histogram shows their brightness and color distributions.
Checked against the current version of the PPM to PNG on .

