LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

pgm

grayscale image format in the Netpbm family

TLDR

View PGM format info
$ pamfile [image.pgm]
copy
Convert JPEG to PGM
$ jpegtopnm [image.jpg] | ppmtopgm > [output.pgm]
copy
Create PGM from text
$ echo "P2 3 2 255 0 128 255 64 192 32" > [output.pgm]
copy
Display PGM image
$ display [image.pgm]
copy

SYNOPSIS

PGM format specification and related utilities

DESCRIPTION

PGM (Portable Graymap) is a grayscale image format in the Netpbm family. It stores images as grayscale values from 0 (black) to maxval (white).Simple ASCII or binary format, easy to read and write programmatically.

FORMAT

$ P2              # ASCII format (P5 for binary)
width height
maxval          # Maximum gray value (usually 255)
pixel_values    # Space-separated (ASCII) or raw (binary)
copy

EXAMPLE FILE

$ P2
# comment
3 2
255
0   128  255
64  192  32
copy

CONVERSIONS

$ # JPEG to PGM
jpegtopnm photo.jpg | ppmtopgm > photo.pgm

# PNG to PGM
pngtopam image.png | pamtopnm | ppmtopgm > image.pgm

# PGM to PNG
pnmtopng image.pgm > image.png
copy

CAVEATS

ASCII format is larger but human-readable. Binary more efficient. Part of Netpbm toolkit.

HISTORY

PGM was designed by Jef Poskanzer as part of the Netpbm (formerly Pbmplus) toolkit for image manipulation.

SEE ALSO

ppm(5), pbm(5), pnm(5), netpbm(1)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid