Debian Codegraph @

upstream/debian-trixie/man5/ppm.5

raw
1 \
2 .\" This man page was generated by the Netpbm tool 'makeman' from HTML source.
3 .\" Do not hand-hack it! If you have bug fixes or improvements, please find
4 .\" the corresponding HTML page on the Netpbm website, generate a patch
5 .\" against that, and send it to the Netpbm maintainer.
6 .TH "PPM Format Specification" 5 "09 October 2016" "netpbm documentation"
7
8 .SH NAME
9
10 PPM - Netpbm color image format
11
12 .UN description
13 .SH DESCRIPTION
14 .PP
15 This program is part of
16 .BR "Netpbm" (1)\c
17 \&.
18 .PP
19 The PPM format is a lowest common denominator color image file
20 format.
21 .PP
22 It should be noted that this format is egregiously inefficient.
23 It is highly redundant, while containing a lot of information that the
24 human eye can't even discern. Furthermore, the format allows very
25 little information about the image besides basic color, which means
26 you may have to couple a file in this format with other independent
27 information to get any decent use out of it. However, it is very easy
28 to write and analyze programs to process this format, and that is the
29 point.
30 .PP
31 It should also be noted that files often conform to this format in
32 every respect except the precise semantics of the sample values.
33 These files are useful because of the way PPM is used as an
34 intermediary format. They are informally called PPM files, but to be
35 absolutely precise, you should indicate the variation from true PPM.
36 For example, "PPM using the red, green, and blue colors that the
37 scanner in question uses."
38 .PP
39 The name "PPM" is an acronym derived from "Portable Pixel Map."
40 Images in this format (or a precursor of it) were once also called
41 "portable pixmaps."
42
43 .UN format
44 .SH THE FORMAT
45 .PP
46 The format definition is as follows. You can use the
47 .BR "libnetpbm" (1)\c
48 \& C subroutine library to read and
49 interpret the format conveniently and accurately.
50 .PP
51 A PPM file consists of a sequence of one or more PPM images. There are
52 no data, delimiters, or padding before, after, or between images.
53 .PP
54 Each PPM image consists of the following:
55
56
57 .IP \(bu
58 A "magic number" for identifying the file type.
59 A ppm image's magic number is the two characters "P6".
60 .IP \(bu
61 Whitespace (blanks, TABs, CRs, LFs).
62 .IP \(bu
63 A width, formatted as ASCII characters in decimal.
64 .IP \(bu
65 Whitespace.
66 .IP \(bu
67 A height, again in ASCII decimal.
68 .IP \(bu
69 Whitespace.
70 .IP \(bu
71 The maximum color value (Maxval), again in ASCII decimal. Must be less
72 than 65536 and more than zero.
73
74 .IP \(bu
75 A single whitespace character (usually a newline).
76
77 .IP \(bu
78 A raster of Height rows, in order from top to bottom. Each row
79 consists of Width pixels, in order from left to right. Each pixel is
80 a triplet of red, green, and blue samples, in that order. Each sample
81 is represented in pure binary by either 1 or 2 bytes. If the Maxval
82 is less than 256, it is 1 byte. Otherwise, it is 2 bytes. The most
83 significant byte is first.
84 .sp
85 A row of an image is horizontal. A column is vertical. The pixels
86 in the image are square and contiguous.
87 .sp
88 In the raster, the sample values are "nonlinear." They are
89 proportional to the intensity of the ITU-R Recommendation BT.709 red,
90 green, and blue in the pixel, adjusted by the BT.709 gamma transfer
91 function. (That transfer function specifies a gamma number of 2.2 and
92 has a linear section for small intensities). A value of Maxval for
93 all three samples represents CIE D65 white and the most intense color
94 in the color universe of which the image is part (the color universe
95 is all the colors in all images to which this image might be
96 compared).
97 .sp
98 BT.709's range of channel values (16-240) is irrelevant to PPM.
99 .sp
100 ITU-R Recommendation BT.709 is a renaming of the former CCIR
101 Recommendation 709. When CCIR was absorbed into its parent
102 organization, the ITU, ca. 2000, the standard was renamed. This
103 document once referred to the standard as CIE Rec. 709, but it isn't
104 clear now that CIE ever sponsored such a standard.
105 .sp
106 Note that another popular color space is the newer sRGB. A common
107 variation from PPM is to substitute this color space for the one specified.
108 You can use \fBpnmgamma\fP to convert between this variation and true PPM.
109 .sp
110 Note that a common variation from the PPM format is to have the sample
111 values be "linear," i.e. as specified above except without
112 the gamma adjustment. \fBpnmgamma\fP takes such a PPM variant as
113 input and produces a true PPM as output.
114
115
116 .PP
117 Strings starting with "#" may be comments, the same as
118 with
119 .BR "PBM" (1)\c
120 \&.
121 .PP
122 Note that you can use \fBpamdepth\fP to convert between the format with 1
123 byte per sample and the one with 2 bytes per sample.
124 .PP
125 All characters referred to herein are encoded in ASCII.
126 "newline" refers to the character known in ASCII as Line
127 Feed or LF. A "white space" character is space, CR, LF,
128 TAB, VT, or FF (I.e. what the ANSI standard C isspace() function
129 calls white space).
130
131 .UN plainppm
132 .SS Plain PPM
133 .PP
134 There is actually another version of the PPM format that is fairly
135 rare: "plain" PPM format. The format above, which generally
136 considered the normal one, is known as the "raw" PPM format.
137 See
138 .BR "\fBpbm\fP " (1)\c
139 \& for some commentary on how plain
140 and raw formats relate to one another and how to use them.
141 .PP
142 The difference in the plain format is:
143
144
145 .IP \(bu
146 There is exactly one image in a file.
147 .IP \(bu
148 The magic number is P3 instead of P6.
149 .IP \(bu
150 Each sample in the raster is represented as an ASCII decimal number
151 (of arbitrary size).
152 .IP \(bu
153 Each sample in the raster has white space before and after it. There must
154 be at least one character of white space between any two samples, but there
155 is no maximum. There is no particular separation of one pixel from another --
156 just the required separation between the blue sample of one pixel from the
157 red sample of the next pixel.
158 .IP \(bu
159 No line should be longer than 70 characters.
160
161 .PP
162 Here is an example of a small image in this format.
163 .nf
164 P3
165 # feep.ppm
166 4 4
167 15
168 0 0 0 0 0 0 0 0 0 15 0 15
169 0 0 0 0 15 7 0 0 0 0 0 0
170 0 0 0 0 0 0 0 15 7 0 0 0
171 15 0 15 0 0 0 0 0 0 0 0 0
172
173 .fi
174 .PP
175 There is a newline character at the end of each of these lines.
176 .PP
177 Programs that read this format should be as lenient as possible,
178 accepting anything that looks remotely like a PPM image.
179
180
181 .UN internetmediatype
182 .SH INTERNET MEDIA TYPE
183 .PP
184 No Internet Media Type (aka MIME type, content type) for PPM has been
185 registered with IANA, but the value \f(CWimage/x-portable-pixmap\fP is
186 conventional.
187 .PP
188 Note that the PNM Internet Media Type \f(CWimage/x-portable-anymap\fP
189 also applies.
190
191
192 .UN filename
193 .SH FILE NAME
194 .PP
195 There are no requirements on the name of a PPM file, but the convention is
196 to use the suffix ".ppm". "pnm" is also conventional, for
197 cases where distinguishing between the particular subformats of PNM is not
198 convenient.
199
200
201 .UN compatibility
202 .SH COMPATIBILITY
203 .PP
204 Before April 2000, a raw format PPM file could not have a maxval greater
205 than 255. Hence, it could not have more than one byte per sample. Old
206 programs may depend on this.
207 .PP
208 Before July 2000, there could be at most one image in a PPM file. As
209 a result, most tools to process PPM files ignore (and don't read) any
210 data after the first image.
211
212 .UN seealso
213 .SH SEE ALSO
214 .BR "pnm" (1)\c
215 \&,
216 .BR "pgm" (1)\c
217 \&,
218 .BR "pbm" (1)\c
219 \&,
220 .BR "pam" (1)\c
221 \&,
222 .BR "programs that process PPM" (1)\c
223 \&
224 .SH DOCUMENT SOURCE
225 This manual page was generated by the Netpbm tool 'makeman' from HTML
226 source. The master documentation is at
227 .IP
228 .B http://netpbm.sourceforge.net/doc/ppm.html
229 .PP