.TH pgm 5 "12 November 1991" .SH NAME pgm - portable graymap file format .SH DESCRIPTION The portable graymap format is a lowest common denominator grayscale file format. .IX "PGM file format" The definition is as follows: .IP - 2 A "magic number" for identifying the file type. A pgm file's magic number is the two characters "P2". .IX "magic numbers" .IP - 2 Whitespace (blanks, TABs, CRs, LFs). .IP - 2 A width, formatted as ASCII characters in decimal. .IP - 2 Whitespace. .IP - 2 A height, again in ASCII decimal. .IP - 2 Whitespace. .IP - 2 The maximum gray value, again in ASCII decimal. .IP - 2 Whitespace. .IP - 2 Width * height gray values, each in ASCII decimal, between 0 and the specified maximum value, separated by whitespace, starting at the top-left corner of the graymap, proceeding in normal English reading order. A value of 0 means black, and the maximum value means white. .IP - 2 Characters from a "#" to the next end-of-line are ignored (comments). .IP - 2 No line should be longer than 70 characters. .PP Here is an example of a small graymap in this format: .nf 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 .fi .PP Programs that read this format should be as lenient as possible, accepting anything that looks remotely like a graymap. .PP There is also a "rawbits" variant on the format. This variant is different in the following ways: .IP - 2 The "magic number" is "P5" instead of "P2". .IP - 2 The gray values are stored as plain bytes, instead of ASCII decimal. .IP - 2 No whitespace is allowed in the grays section, and only a single character of whitespace, typically a newline, is allowed after the maxval. (This last requirement is actually due to a botch in the design of the file format.) .IP - 2 The files are smaller and many times faster to read and write. .PP If maxval is between 256 and 65535, the gray values are stored as two bytes, low byte first and high byte second. Images with maxval higher than 65535 must be written in the slower but more general plain format. .SH "SEE ALSO" pbmplus(1), pbm(5), ppm(5), pnm(5) .SH AUTHOR Copyright (C) 1989, 1991, 1999 by Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty.