JPG to PGM Converter

Make a grayscale PGM from a color JPG for scripts and research tools, right in your browser.

or drop files here

JP

JPG Format

JPEG image

A lossy photo format with 8 bits per color channel. The .jpg and .jpeg extensions name the same format, and it cannot hold layers.

  • Lossy compression
  • Color photographs
  • No transparency
  • Image media type image/jpeg
PG

PGM Format

Portable Gray Map

The grayscale member of the Netpbm family. Raw files start with P5 and plain-text files with P2.

  • Gray samples only
  • Raw form starts with P5
  • Plain form starts with P2
  • Maximum value above 255 needs two bytes

How to convert JPG to PGM

Follow these steps to convert JPG to PGM online.

    1

    Choose your JPG file, or several at once.

    2

    Wait while the converter turns each file into PGM.

    3

    Download each new PGM file. Your original file isn't changed.

What to know before converting JPG to PGM

  • Color is gone; the PGM keeps only brightness.
  • The PGM is written in the raw P5 form.
  • Green counts most toward the gray and blue least.
  • EXIF, ICC profiles and XMP are not carried over.
  • Each JPG in a batch gives its own PGM.

About JPG files

What is a JPG file?

Most cameras and scanners save their pictures as JPG. Each color channel gets 8 bits, transparency is not available, and fine detail is discarded to keep files small. A file may end in .jpg or .jpeg, and its media type is image/jpeg.

Because the compression is lossy, a PGM made from a JPG cannot recover what the JPG already threw away. Pictures are compressed in blocks of 8x8 pixels, and whatever blockiness is present in the color file remains visible in gray.

Programs that open JPG files

  • Windows, Mac and Linux: ImageMagick reads JPG, and GIMP brings one in for editing.
  • Web and Mobile: Chrome displays JPG.
  • Web: Firefox displays JPG.
  • Mobile: Safari displays JPG.

JPG and PGM compared

PGM stands for Portable Gray Map, a Netpbm format that stores only gray samples. A raw file starts with P5 and keeps samples in binary, while a plain file starts with P2 and writes them as decimal text. With a maximum value above 255, each raw sample takes two bytes. The conventional media type is image/x-portable-graymap, and IANA has not registered it. Some Netpbm tools reuse the format for opacity masks, reading the samples as opacity, not brightness.

On this page your browser first decodes the picture, then ImageMagick in WebAssembly produces the PGM.

Other ways to convert JPG to PGM

  • Pillow: in Python, Image.open("photo.jpg").convert("L").save("photo.pgm") applies the ITU-R 601-2 luma transform from the Pillow reference. Pillow reads and writes PGM.
  • Netpbm: run jpegtopnm photo.jpg | ppmtopgm > photo.pgm. The ppmtopgm step weights red, green and blue as .299, .587 and .114.
  • GIMP: load the JPG, then File > Export As with the name photo.pgm; ASCII or RAW is chosen under Data formatting.

Problems with JPG files

  • Matching numbers, different results: two editors set to the same quality may compress differently, so a re-saved copy may not look like the first.
  • A photo frame rejects the source: some older frames refuse progressive JPEG, so save a copy with progressive mode disabled.
  • No editable layers: layers are not stored in a JPG, so hold on to the project file you edited.

Frequently Asked Questions

Everything you need to know about our converter

What are the steps to turn a JPG into a PGM?

Does the PGM have gray levels or only black and white?

How is color turned into gray?

Why would I want a PGM?

What is the difference between P2 and P5?

Can a PGM hold more than 8 bits per pixel?

Are EXIF and color profiles kept?

Does the page take .jpeg files too?