VOOZH about

URL: https://manpages.org/pgm/5

⇱ man pgm (5): portable graymap file format


pgm(5) portable graymap file format

DESCRIPTION

The PGM format is a lowest common denominator grayscale file format.

pbm(5) for some commentary on how plain and raw formats relate to one another.

The difference in the plain format is:

-
There is exactly one image in a file.
-
The magic number is P2 instead of P5.
-
Each pixel in the raster is represented as an ASCII decimal number (of arbitrary size).
-
Each pixel in the raster has white space before and after it. There must be at least one character of white space between any two pixels, but there is no maximum.
-
No line should be longer than 70 characters.

Here is an example of a small graymap in this format:

P2
# feep.pgm
24 7
15
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 3 3 3 3 0 0 7 7 7 7 0 0 11 11 11 11 0 0 15 15 15 15 0
0 3 0 0 0 0 0 7 0 0 0 0 0 11 0 0 0 0 0 15 0 0 15 0
0 3 3 3 0 0 0 7 7 7 0 0 0 11 11 11 0 0 0 15 15 15 15 0
0 3 0 0 0 0 0 7 0 0 0 0 0 11 0 0 0 0 0 15 0 0 0 0
0 3 0 0 0 0 0 7 7 7 7 0 0 11 11 11 11 0 0 15 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Programs that read this format should be as lenient as possible, accepting anything that looks remotely like a graymap.

COMPATIBILITY

Before April 2000, a raw format PGM file could not have a maxval greater than 255. Hence, it could not have more than one byte per sample. Old programs may depend on this.

Before July 2000, there could be at most one image in a PGM file. As a result, most tools to process PGM files ignore (and don't read) any data after the first image.

AUTHOR

Copyright (C) 1989, 1991 by Jef Poskanzer.