1PPM Format Specification(5)   File Formats Manual  PPM Format Specification(5)
2
3
4

NAME

6       PPM - Netpbm color image format
7
8

DESCRIPTION

10       This program is part of Netpbm(1).
11
12       The PPM format is a lowest common denominator color image file format.
13
14       It  should be noted that this format is egregiously inefficient.  It is
15       highly redundant, while containing a lot of information that the  human
16       eye  can't  even  discern.   Furthermore, the format allows very little
17       information about the image besides basic color, which  means  you  may
18       have to couple a file in this format with other independent information
19       to get any decent use out of it.  However, it is very easy to write and
20       analyze programs to process this format, and that is the point.
21
22       It  should  also  be  noted  that files often conform to this format in
23       every respect except the precise semantics of the sample values.  These
24       files are useful because of the way PPM is used as an intermediary for‐
25       mat.  They are informally called PPM files, but to be  absolutely  pre‐
26       cise,  you  should  indicate the variation from true PPM.  For example,
27       "PPM using the red, green, and blue colors that the scanner in question
28       uses."
29
30       The name "PPM" is an acronym derived from "Portable Pixel Map."  Images
31       in this format (or a precursor of it) were once also  called  "portable
32       pixmaps."
33
34

THE FORMAT

36       The  format  definition  is as follows.  You can use the libnetpbm(1) C
37       subroutine library to read and interpret the  format  conveniently  and
38       accurately.
39
40       A  PPM file consists of a sequence of one or more PPM images. There are
41       no data, delimiters, or padding before, after, or between images.
42
43       Each PPM image consists of the following:
44
45
46
47       ·      A "magic number" for identifying the file type.  A  ppm  image's
48              magic number is the two characters "P6".
49
50       ·
51
52              Whitespace (blanks, TABs, CRs, LFs).
53
54       ·
55
56              A width, formatted as ASCII characters in decimal.
57
58       ·
59
60              Whitespace.
61
62       ·
63
64              A height, again in ASCII decimal.
65
66       ·
67
68              Whitespace.
69
70       ·
71
72              The  maximum color value (Maxval), again in ASCII decimal.  Must
73              be less than 65536 and more than zero.
74
75
76       ·      A single whitespace character (usually a newline).
77
78
79       ·      A raster of Height rows, in order from top to bottom.  Each  row
80              consists  of  Width  pixels,  in order from left to right.  Each
81              pixel is a triplet of red, green,  and  blue  samples,  in  that
82              order.  Each sample is represented in pure binary by either 1 or
83              2 bytes.  If the Maxval is less than 256, it is 1 byte.   Other‐
84              wise, it is 2 bytes.  The most significant byte is first.
85
86              A  row  of  an  image is horizontal.  A column is vertical.  The
87              pixels in the image are square and contiguous.
88
89              In the raster, the sample values are "nonlinear." They are  pro‐
90              portional  to  the  intensity of the ITU-R Recommendation BT.709
91              red, green, and blue in the pixel, adjusted by the BT.709  gamma
92              transfer  function.   (That  transfer function specifies a gamma
93              number of 2.2 and has a linear section for  small  intensities).
94              A value of Maxval for all three samples represents CIE D65 white
95              and the most intense color in the color universe  of  which  the
96              image  is  part  (the  color  universe  is all the colors in all
97              images to which this image might be compared).
98
99              BT.709's range of channel values (16-240) is irrelevant to PPM.
100
101              ITU-R Recommendation BT.709 is a renaming  of  the  former  CCIR
102              Recommendation  709.   When  CCIR  was  absorbed into its parent
103              organization, the ITU, ca. 2000, the standard was renamed.  This
104              document  once  referred to the standard as CIE Rec. 709, but it
105              isn't clear now that CIE ever sponsored such a standard.
106
107              Note that another popular color space is the newer sRGB.  A com‐
108              mon variation from PPM is to substitute this color space for the
109              one specified.  You can use pnmgamma  to  convert  between  this
110              variation and true PPM.
111
112              Note  that a common variation from the PPM format is to have the
113              sample values be "linear," i.e. as specified above except  with‐
114              out  the gamma adjustment.  pnmgamma takes such a PPM variant as
115              input and produces a true PPM as output.
116
117
118
119       Strings starting with "#" may be comments, the same as with PBM(1).
120
121       Note that you can use pamdepth to convert between a the format  with  1
122       byte per sample and the one with 2 bytes per sample.
123
124       All  characters  referred  to  herein  are encoded in ASCII.  "newline"
125       refers to the character known in ASCII as Line Feed or  LF.   A  "white
126       space"  character  is space, CR, LF, TAB, VT, or FF (I.e. what the ANSI
127       standard C isspace() function calls white space).
128
129
130   Plain PPM
131       There is actually another version of the  PPM  format  that  is  fairly
132       rare: "plain" PPM format.  The format above, which generally considered
133       the normal one, is known as the "raw" PPM format.  See pbm(1) for  some
134       commentary  on  how plain and raw formats relate to one another and how
135       to use them.
136
137       The difference in the plain format is:
138
139
140
141       ·
142
143              There is exactly one image in a file.
144
145       ·
146
147              The magic number is P3 instead of P6.
148
149       ·
150
151              Each sample in the raster is represented  as  an  ASCII  decimal
152              number (of arbitrary size).
153
154       ·
155
156              Each  sample  in the raster has white space before and after it.
157              There must be at least one character of white space between  any
158              two  samples,  but  there is no maximum.  There is no particular
159              separation of one pixel from another -- just the required  sepa‐
160              ration  between the blue sample of one pixel from the red sample
161              of the next pixel.
162
163       ·
164
165              No line should be longer than 70 characters.
166
167
168       Here is an example of a small image in this format.
169       P3
170       # feep.ppm
171       4 4
172       15
173        0  0  0    0  0  0    0  0  0   15  0 15
174        0  0  0    0 15  7    0  0  0    0  0  0
175        0  0  0    0  0  0    0 15  7    0  0  0
176       15  0 15    0  0  0    0  0  0    0  0  0
177
178       There is a newline character at the end of each of these lines.
179
180       Programs that read this  format  should  be  as  lenient  as  possible,
181       accepting anything that looks remotely like a PPM image.
182
183
184

INTERNET MEDIA TYPE

186       No  Internet  Media Type (aka MIME type, content type) for PPM has been
187       registered with IANA, but the value image/x-portable-pixmap is  conven‐
188       tional.
189
190       Note  that  the  PNM  Internet  Media Type image/x-portable-anymap also
191       applies.
192
193
194

FILE NAME

196       There are no requirements on the name of a PPM file, but the convention
197       is  to  use  the  suffix ".ppm".  "pnm" is also conventional, for cases
198       where distinguishing between the particular subformats of  PNM  is  not
199       convenient.
200
201
202

COMPATIBILITY

204       Before  April  2000,  a  raw  format  PPM  file could not have a maxval
205       greater than 255.  Hence, it could not have more than one byte per sam‐
206       ple.  Old programs may depend on this.
207
208       Before July 2000, there could be at most one image in a PPM file.  As a
209       result, most tools to process PPM files ignore  (and  don't  read)  any
210       data after the first image.
211
212

SEE ALSO

214       pnm(1), pgm(1), pbm(1), pam(1), programs that process PPM(1)
215

DOCUMENT SOURCE

217       This  manual  page was generated by the Netpbm tool 'makeman' from HTML
218       source.  The master documentation is at
219
220              http://netpbm.sourceforge.net/doc/ppm.html
221
222netpbm documentation            09 October 2016    PPM Format Specification(5)
Impressum