PGM to JPG Converter
PGM files hold greyscale pictures in a very simple format used by image-processing code, computer vision datasets and lab software. They rarely open in everyday programs. This page reads PGM in your browser, in either the text or the binary layout, and gives you a normal JPG to view, share or attach, with no upload.
Embed this tool on your websiteShow code
Free to use on any site. Paste the code where you want the tool to appear. It runs inside the page; visitors' files are processed in their own browser and are not uploaded.
WordPress and most site builders have a "Custom HTML" block where this code can be pasted. The embed keeps a small link back to CalcMaster.
How to convert PGM to JPG
- Add your PGM files by dropping them, clicking the drop zone or pasting.
- The output format is already set to JPG. Adjust quality or size if you need to.
- Press Convert and compare the original and new size for each file.
- Download each file or all of them as a ZIP.
When to convert, and when not to
- You exported a greyscale image from a script, course exercise or dataset and want to view it easily.
- A report or website needs a picture, and the PGM will not open in your editor.
- You want a preview of many greyscale files in one folder.
- Do not convert measurement data you still need to analyse. Keep the PGM, because the JPG loses precision, especially from 16-bit files.
What changes
- Plain-text and binary PGM are both read, with either 8-bit or 16-bit brightness values.
- Brightness values are scaled to the ordinary 0 to 255 range that JPG uses, so 16-bit detail is reduced.
- The result is a greyscale-looking picture saved as a standard colour JPG, which every program can open.
- PGM has no transparency, so the background colour option normally changes nothing.
- Header comments, which some programs add to PGM files, are not written to the JPG.
What a PGM file stores
PGM stands for portable graymap. It stores one brightness number per pixel, from black to white, with an upper limit written in the header. The format is intentionally easy to read and write, which is why research code and teaching material use it so much.
Like its relatives PBM and PPM, it comes in a text form and a binary form. The text form can be opened in an editor and shows the pixels as numbers. The binary form holds the same numbers in bytes. The converter works out which one it has from the file's first characters.
Eight-bit and sixteen-bit images
When the upper limit in the header is small, each pixel needs one byte. When it is larger, each pixel uses two bytes, which allows a much finer ladder of greys. Medical and scientific images often use the second kind.
Screens and standard JPGs show only a few hundred grey levels, so the converter scales the values down to fit. The result looks right but contains less precision. For analysis work, keep the original PGM file and treat the JPG as a picture to look at.
Choosing quality for a greyscale picture
Smooth gradients in greyscale images can show visible banding or blockiness if the JPG quality is low. A fairly high setting is a good starting point for dataset previews. Convert one sample and zoom in before you run a folder.
If you plan to feed the result back into software that measures pixel values, PNG is the better output because it keeps eight-bit values exactly. JPG is best when the goal is simply a viewable picture of manageable size.
Datasets and previews
Computer vision and teaching datasets often ship hundreds of PGM files in numbered folders. Add a whole folder's worth, convert, and download a ZIP of JPG previews to flip through quickly. Files are processed one at a time, which keeps memory use gentle, though a phone may still struggle with very large images, so try a few first.
Privacy: your files stay on your device
- The tool decodes, resizes and encodes your pictures with your browser. The files are never sent to a server.
- To check it yourself: open the browser developer tools (F12), open the Network tab, convert a file, and look for any request that carries your image. You will see none.
Frequently asked questions
Is the converted JPG still greyscale?
It looks greyscale. The tool writes ordinary red, green and blue values that are all equal, so every program can open it.
What happens to 16-bit PGM files?
Their values are scaled down to the usual 0 to 255 range. The picture looks the same, but the extra precision is lost.
Can I convert both text and binary PGM?
Yes. The tool reads both layouts automatically.
Should I use PNG instead?
Choose PNG if you need exact eight-bit values or plan to process the image again. JPG is for viewing and sharing.
Is anything uploaded?
No. Your PGM files are read and converted in your browser and stay on your device.