PPM vs PNG: technical differences
To convert PPM to PNG, drop your PPM file into the converter above and download the PNG: a lossless format that keeps transparency and every pixel exactly. It is free, needs no sign-up, and runs in your browser, so the file is never uploaded.
PPM is what programs write when they want to output an image with zero dependencies: a header like “P3 800 450 255” followed by every pixel's red, green and blue values, either as ASCII numbers (P3) or raw bytes (P6). PNG stores the same 8-bit RGB values losslessly, but compressed with DEFLATE, and it opens everywhere. That combination makes ppm to png the standard way to share a program's output.
Size drops substantially. A 1920 × 1080 binary P6 is about 6.2 MB, and an ASCII P3 of the same image is typically 3–4× larger again. As PNG, smooth renders and synthetic test images often shrink to a few hundred KB. Noisy path-traced output compresses less, but it's still much smaller than raw.
Pixohub reads P6 and P3 and rescales any maxval to the 0–255 range. Two limits: binary P6 files with maxval above 255 (16-bit, two bytes per sample) aren't decoded correctly, and other Netpbm types (PGM P2/P5, PBM P1/P4, PAM P7) aren't supported. PPM has no alpha, so the PNG is fully opaque.
| PPM (Portable Pixmap (Netpbm)) | PNG (Portable Network Graphics) | |
|---|---|---|
| Compression | None (raw binary P6 or ASCII P3) | Lossless (DEFLATE with per-row prediction filters) |
| Colour depth | 8 or 16 bits per channel, RGB only | 1–16 bits per channel; truecolor, greyscale or 256-colour palette |
| Transparency | None | Full 8/16-bit alpha channel |
| Animation | None | Only via the APNG extension |
| Metadata | Comment lines in the header only | Text chunks, ICC profile, gamma; EXIF via the newer eXIf chunk |
| Typical file size | Very large — exactly width × height × 3 bytes plus a header | Large for photos (often 2–3× a JPG); tiny for flat graphics |
| Support | Image-processing libraries, Netpbm, GIMP; not browsers | Universal — every browser, OS and editor |
When to convert PPM to PNG
Sharing your ray tracer's output
The well-known Ray Tracing in One Weekend series has you write a P3 PPM to standard output. Converting it to PNG lets you post the render in a course forum, a README or a portfolio, without losing a single pixel.
Viewing images from C/C++ or Python exercises
Browsers, Windows Photos and chat apps can't display PPM. A PNG is the quickest way to actually look at what your convolution filter, fractal generator or rasteriser produced.
Frames dumped by ffmpeg or OpenCV
Tools sometimes write PPM frames for speed (for example ffmpeg -i clip.mp4 frame%04d.ppm). Converting the frames you need to PNG keeps them lossless and far smaller.
What converting PPM to PNG keeps and loses
What you keep
- Every pixel's RGB value exactly (for 8-bit PPMs).
- Resolution and row order.
- The image as your program wrote it. No gamma, colour profile or sharpening is applied.
What you lose
- Header comment lines (# …), which PNG doesn't carry over here.
- Precision above 8 bits: P3 files with maxval 65535 are scaled down to 8-bit.
- Nothing visible for standard maxval-255 files.
Our test: PPM to PNG on two real files
Both PPMs converted with identical pixels. The photo went from 5.8 MB to 3.2 MB, a 44% saving, which is about what lossless compression manages on camera noise. The opaque graphic fell from 1.4 MB to 284 KB, 80% smaller, because flat areas and gradients compress well.
Expect noisy renders to behave like the photo and clean synthetic images like the graphic. Neither conversion took more than 1.6 s on our test machine.
Method: this converter in Chromium (Playwright 1.64.1) on an Apple M2 Mac, default 85% quality for lossy output. The photo is an iPhone 14 Pro Max shot scaled to 1600 × 1200, metadata intact; the graphic has a transparent background, soft shadow, gradients and text. SSIM and PSNR compare each result with the decoded original on white (how we test).
| Test file | PPM in | PNG out | Pixels vs original | Transparency | Camera EXIF | Time |
|---|---|---|---|---|---|---|
| Photo, 1600 × 1200 | 5.8 MB | 3.2 MB (−44%) | Identical pixels | None in source | None in source | 1.6 s |
| Graphic, 800 × 600, transparent | 1.4 MB | 284 KB (−80%) | Identical pixels | None in source | None in source | 1.0 s |
Last updated
Apps and sites that work with PPM and PNG
Programs that write PPM
POV-Ray writes PPM with its +FP switch, and many C, C++ and Rust graphics tutorials output P3 or P6 because it needs no library. Netpbm tools and ffmpeg write it too. Converting their output to PNG is the usual last step before sharing.
GitHub and READMEs
GitHub renders PNG inline in READMEs, issues and pull requests, but shows a .ppm as a binary file you have to download. Converting is the only way to show a render in a project's front page. The same applies to GitLab and most documentation sites.
Viewers if you'd rather not convert
GIMP, IrfanView, feh and the GNOME image viewer open PPM directly, which is enough for a quick look on your own machine. Anything you share needs PNG. On Windows IrfanView is the lightest of these; on Linux, feh or the default viewer usually works out of the box.
Common PPM to PNG problems and fixes
“Unsupported or invalid PPM file.”
Bulk Format Convert shows this message, and this page a generic alert, when the file doesn't start with P3 or P6, or its width or height can't be read. Greyscale PGM (P2, P5), bitmap PBM (P1, P4) and PAM (P7) files are the usual cause. Convert them with Netpbm (pgmtoppm, pamtopnm) or write RGB from your program.
A sheared or striped picture
Pixohub reads exactly the width and height the header declares. If your program writes a different number of pixels per row than it announces, every row starts in the wrong place and the image shears diagonally. Check that the header and your loops use the same width. A 1600 × 1200 P6 must contain exactly 5,760,000 bytes of pixel data after the header.
Stripes or wrong colours in a P3 file
P3 values must be separated by spaces or newlines only. Printing them with commas or brackets, for example straight from a Python list, makes the reader treat several numbers as one, so colours drift out of step. Write them with spaces. Comment lines starting with # are skipped, so those are safe.
Bulk ignores .pnm files
Bulk Format Convert picks the PPM reader by the .ppm extension, so a .pnm file falls through to the browser, which can't decode it. Rename it to .ppm. This page uses the PPM reader for any file you choose. Files saved as .pbm or .pgm are different formats and won't decode either way.
Tips for better PPM to PNG results
- Windows PowerShell 5 writes UTF-16 when you redirect with >, which produces a PPM no reader accepts. Run the program from cmd.exe, use PowerShell 7, or write the file directly from your code.
- Render looks too dark? That's usually a missing gamma-correction step in your program (for example, taking the square root of linear values for gamma 2). The converter shows values exactly as written.
How this converter works
Pixohub decodes your PPM and encodes the PNG entirely inside your browser, using a bundled PPM decoder because browsers cannot open PPM natively. Nothing is uploaded, so the conversion is private by design and as fast as your device.
Need more? Shrink the result with the image compressor, change its dimensions with the image resizer, or convert a whole folder at once with bulk format convert.