1PAM format specification(5)   File Formats Manual  PAM format specification(5)
2
3
4

NAME

6       pam - Netpbm common 2-dimensional bitmap format
7
8

GENERAL

10       The  PAM  image format is a lowest common denominator 2 dimensional map
11       format.
12
13       It is designed to be used for any of myriad kinds of graphics, but  can
14       theoretically  be  used  for any kind of data that is arranged as a two
15       dimensional rectangular array.  Actually, from another  perspective  it
16       can be seen as a format for data arranged as a three dimensional array.
17
18       The  name  "PAM"  is  an acronym derived from "Portable Arbitrary Map."
19       This derivation makes more sense if you consider it in the  context  of
20       the other Netpbm format names: PBM, PGM, and PPM.
21
22       This  format  does not define the meaning of the data at any particular
23       point in the array.  It could be red, green, and blue light intensities
24       such  that the array represents a visual image, or it could be the same
25       red, green, and blue components plus a transparency  component,  or  it
26       could  contain annual rainfalls for places on the surface of the Earth.
27       Any process that uses the PAM format must further define the format  to
28       specify the meanings of the data.
29
30       A PAM image describes a two dimensional grid of tuples.  The tuples are
31       arranged in rows and columns.  The width of the image is the number  of
32       columns.   The height of the image is the number of rows.  All rows are
33       the same width and all columns are the same  height.   The  tuples  may
34       have  any  degree,  but all tuples have the same degree.  The degree of
35       the tuples is called the depth of the image.  Each member of a tuple is
36       called  a  sample.   A sample is an unsigned integer which represents a
37       locus along a scale which starts at zero and ends at a certain  maximum
38       value  called  the  maxval.  The maxval is the same for every sample in
39       the image.  The two dimensional array of all the Nth  samples  of  each
40       tuple is called the Nth plane or Nth channel of the image.
41
42       Though  the  basic format does not assign any meaning to the tuple val‐
43       ues, it does include an optional string that  describes  that  meaning.
44       The  contents of this string, called the tuple type, are arbitrary from
45       the point of view of the basic PAM format, but users of the format  may
46       assign  meaning to it by convention so they can identify their particu‐
47       lar implementations of the PAM format.  Some tuple types are defined as
48       official subformats of PAM.  See Defined Tuple Types ⟨#tupletype⟩ .
49
50

The Confusing Universe of Netpbm Formats

52       It  is easy to get confused about the relationship between the PAM for‐
53       mat and PBM, PGM, PPM, and PNM.  Here is a little enlightenment:
54
55       "PNM" is not really a format.  It is a shorthand for the PBM, PGM,  and
56       PPM  formats  collectively.   It is also the name of a group of library
57       functions that can each handle all three of those formats.
58
59       "PAM" is in fact a fourth format.  But it is so general  that  you  can
60       represent the same information in a PAM image as you can in a PBM, PGM,
61       or PPM image.  And in fact a program that is designed to read PBM, PGM,
62       or  PPM  and  does  so with a recent version of the Netpbm library will
63       read an equivalent PAM image just fine and the program will never  know
64       the difference.
65
66       To  confuse  things  more,  there  is  a collection of library routines
67       called the "pam" functions that read and write the PAM format, but also
68       read and write the PBM, PGM, and PPM formats.  They do this because the
69       latter formats are much older and more popular, so even a  new  program
70       must  work  with them.  Having the library handle all the formats makes
71       it convenient to write programs that use the newer PAM format as well.
72
73

THE LAYOUT

75       A convenient way to read and write the PAM format accurately is via the
76       libnetpbm(1) C subroutine library.
77
78       A PAM file consists of a sequence of one or more PAM images.  There are
79       no data, delimiters, or padding before, after, or between images.
80
81       Each PAM image consists of a header followed immediately by a raster.
82
83       Here is an example header:
84
85
86       P7
87       WIDTH 227
88       HEIGHT 149
89       DEPTH 3
90       MAXVAL 255
91       TUPLTYPE RGB
92       ENDHDR
93
94
95
96       The header begins with the ASCII characters "P7" followed  by  newline.
97       This is the magic number.
98
99       Note: xv thumbnail images also start with the "P7" magic number.  (This
100       and PAM were independent extensions to the Netpbm formats).   The  rest
101       of  the  format  makes  it  easy  to  distinguish PAM from that format,
102       though).
103
104       The header continues with an arbitrary number of lines of  ASCII  text.
105       Each line ends with and is delimited by a newline character.
106
107       Each  header  line consists of zero or more whitespace-delimited tokens
108       or begins with "#".  If it begins with "#" it is a comment and the rest
109       of this specification does not apply to it.
110
111       A header line which has zero tokens is valid but has no meaning.
112
113       The  type  of  header line is identified by its first token, which is 8
114       characters or less:
115
116
117
118       ENDHDR This is the last line in the header.  The  header  must  contain
119              exactly one of these header lines.
120
121
122       HEIGHT The  second token is a decimal number representing the height of
123              the image (number of rows).  The header must contain exactly one
124              of these header lines.
125
126
127       WIDTH  The  second  token is a decimal number representing the width of
128              the image (number of columns).  The header must contain  exactly
129              one of these header lines.
130
131
132       DEPTH  The  second  token is a decimal number representing the depth of
133              the image (number of planes or channels).  The header must  con‐
134              tain exactly one of these header lines.
135
136
137       MAXVAL The  second token is a decimal number representing the maxval of
138              the image.  The header must contain exactly one of these  header
139              lines.
140
141
142       TUPLTYPE
143              The header may contain any number of these header lines, includ‐
144              ing zero.  The rest of the line is part of the tuple type.   The
145              rest  of  the line is not tokenized, but the tuple type does not
146              include any white space immediately following  TUPLTYPE   or  at
147              the very end of the line.  It does not include a newline.  There
148              must be something other than white space after the TUPLTYPE  to‐
149              ken.
150
151              If  there  are multiple TUPLTYPE header lines, the tuple type is
152              the concatenation of the values from each of them, separated  by
153              a single blank, in the order in which they appear in the header.
154              If there are no TUPLTYPE header lines the tuple type is the null
155              string.
156
157
158
159       The raster consists of each row of the image, in order from top to bot‐
160       tom, consecutive with no delimiter of any kind between, before, or  af‐
161       ter, rows.
162
163       Each  row  consists  of  every  tuple in the row, in order from left to
164       right, consecutive with no delimiter of any kind  between,  before,  or
165       after, tuples.
166
167       Each tuple consists of every sample in the tuple, in order, consecutive
168       with no delimiter of any kind between, before, or after, samples.
169
170       Each sample consists of an unsigned integer in pure binary format, with
171       the  most  significant  byte first.  The number of bytes is the minimum
172       number of bytes required to represent the maxval of the image.
173
174       The character referred to as "newline" herein is the character known in
175       ASCII as Line Feed or LF.
176
177

LIMITATIONS

179       Height, width, depth, and maxval are at least 1.
180
181       Height,  width,  and  depth have no defined maximum, but processors and
182       generators of images usually have their own limitations.
183
184       The maxval of an image is never greater than 65535.  (The reason it  is
185       limited  is to make it easier to build an image processor, in which in‐
186       termediate arithmetic values often have to fit within 31 or  32  bits).
187       There was no specified limitation before October, 2005, but essentially
188       all implementations have always observed it.
189
190

DEFINED TUPLE TYPES

192       Some tuple types are defined in this specification to specify  official
193       subformats  of  PAM  for especially popular applications of the format.
194       Users of the format may also define their own  tuple  types,  and  thus
195       their own subformats.
196
197       Tuple type affects only the meanings of the samples (which are unsigned
198       integers) in the tuples of the image.  It does not affect how the  sam‐
199       ples or tuples are encoded.  Tuple type may affect the meaning of a tu‐
200       ple's position in the array (e.g. it may indicate  in  a  visual  image
201       that  a  tuple  in Row 1 is one at the top of the image rather than the
202       bottom).
203
204       Tuple type never determines how many samples are in a  tuple  (that  is
205       instead determined by the DEPTH header line).  Tuple type could be said
206       to imply a depth (number of samples per tuple)  because  certain  tuple
207       types  are  valid only in combination with certain DEPTH values, but it
208       is good programming practice to use DEPTH for the depth  when  decoding
209       the  raster  and  separately validate that the depth is consistent with
210       the tuple type.  Also, it is good practice to accept a  depth  that  is
211       too great and just ignore the higher numbered planes.
212
213
214   PAM Used For Visual Images
215       A  common  use  of PAM images is to represent visual images such as are
216       typically represented by images in the older  and  more  concrete  PBM,
217       PGM, and PPM formats.
218
219       Black And White
220
221       A  black and white image, such as would alternatively be represented by
222       a PBM image, has a tuple type of "BLACKANDWHITE".  Such a PAM image has
223       a  depth  of  1 and maxval 1 where the one sample in each tuple is 0 to
224       represent a black pixel and 1 to represent a white  one.   The  maxval,
225       height, width, and order of tuples in the raster bear the obvious rela‐
226       tionship to those of the equivalent PGM image.
227
228       Note that in the PBM format, a sample value of zero means white, but in
229       PAM, zero means black.
230
231       Grayscale
232
233       A  grayscale image, such as would alternatively be represented by a PGM
234       image, has a tuple type of "GRAYSCALE".  Such a PAM image has  a  depth
235       of 1.  The maxval, height, width, and raster bear the obvious relation‐
236       ship to those of the equivalent PGM image.
237
238       Color
239
240       A color image, such as would alternatively be represented by a PPM  im‐
241       age,  has  a  tuple  type of "RGB".  Such a PAM image has a depth of 3.
242       The maxval, height, width, and raster bear the obvious relationship  to
243       those  of  the  PPM  image.  The first plane represents red, the second
244       green, and the third blue.
245
246       Transparent
247
248       Each of the visual image formats mentioned above has a  variation  that
249       contains  transparency  information.  In that variation, the tuple type
250       has "_ALPHA" added to it (e.g. "RGB_ALPHA") and one  more  plane.   The
251       highest  numbered plane is the opacity plane (sometimes called an alpha
252       plane or transparency plane).
253
254       In this kind of image, the color represented by a pixel is  actually  a
255       combination  of  an  explicitly  specified foreground color and a back‐
256       ground color to be identified later.
257
258       The planes other than the opacity plane describe the foreground  color.
259       A sample in the opacity plane tells how opaque the pixel is, by telling
260       what fraction of the pixel's light comes  from  the  foreground  color.
261       The  rest  of the pixel's light comes from the (unspecified) background
262       color.
263
264       For example, in a GRAYSCALE_ALPHA image, assume  Plane  0  indicates  a
265       gray  tone  60%  of white and Plane 1 indicates opacity 25%.  The fore‐
266       ground color is the 60% gray, and 25% of that contributes to the  ulti‐
267       mate  color  of  the  pixel.   The other 75% comes from some background
268       color.  So let's assume further that the background color of the  pixel
269       is  full  white.   Then the color of the pixel is 90% of white:  25% of
270       the foreground 60%, plus 75% of the background 100%.
271
272       The sample value is the opacity fraction just described, as a  fraction
273       of  the maxval.  Note that it is not gamma-adjusted like the foreground
274       color samples.
275
276
277

INTERNET MEDIA TYPE

279       No Internet Media Type (aka MIME type, content type) for PBM  has  been
280       registered  with  IANA, but the unofficial value image/x-portable-arbi‐
281       trarymap is assigned by this specification, to be consistent with  con‐
282       ventional values for the older Netpbm formats.
283
284

FILE NAME

286       The conventional suffix for the name of a PAM file is ".pam".  But this
287       is not required.
288
289
290

SEE ALSO

292       Netpbm(1), pbm(1), pgm(1), ppm(1), pnm(1), libnetpbm(1)
293

DOCUMENT SOURCE

295       This manual page was generated by the Netpbm tool 'makeman'  from  HTML
296       source.  The master documentation is at
297
298              http://netpbm.sourceforge.net/doc/pam.html
299
300netpbm documentation           27 November 2013    PAM format specification(5)
Impressum