1The PBM Format(5)             File Formats Manual            The PBM Format(5)
2
3
4

NAME

6       pbm - Netpbm bi-level image format
7
8

DESCRIPTION

10       This program is part of Netpbm(1).
11
12       The  PBM  format is a lowest common denominator monochrome file format.
13       It serves as the common language of a large family of bitmap image con‐
14       version  filters.  Because the format pays no heed to efficiency, it is
15       simple and general enough that one can easily develop programs to  con‐
16       vert to and from just about any other graphics format, or to manipulate
17       the image.
18
19       The name "PBM" is an acronym derived from "Portable Bit Map."
20
21       This is not a format that one would normally use to store a file or  to
22       transmit  it to someone -- it's too expensive and not expressive enough
23       for that.  It's just an intermediary format.  In it's  purest  use,  it
24       lives only in a pipe between two other programs.
25
26

THE LAYOUT

28       The format definition is as follows.
29
30       A  PBM file consists of a sequence of one or more PBM images. There are
31       no data, delimiters, or padding before, after, or between images.
32
33       Each PBM image consists of the following:
34
35
36
37
38       •      A "magic number" for identifying the file type.  A  pbm  image's
39              magic number is the two characters "P4".
40
41
42       •      Whitespace (blanks, TABs, CRs, LFs).
43
44
45       •      The  width in pixels of the image, formatted as ASCII characters
46              in decimal.
47
48
49       •      Whitespace.
50
51
52       •      The height in pixels of the image, again in ASCII decimal.
53
54
55       •      A single whitespace character (usually a newline).
56
57
58       •      A raster of Height rows, in order from top to bottom.  Each  row
59              is  Width bits, packed 8 to a byte, with don't care bits to fill
60              out the last byte in the row.  Each bit represents a pixel: 1 is
61              black,  0  is  white.  The order of the pixels is left to right.
62              The order of their storage within each file byte is most signif‐
63              icant bit to least significant bit.  The order of the file bytes
64              is from the beginning of the file toward the end of the file.
65
66              A row of an image is horizontal.  A  column  is  vertical.   The
67              pixels in the image are square and contiguous.
68
69
70       •      Before  the  whitespace  character that delimits the raster, any
71              characters from a "#" through the next carriage return  or  new‐
72              line  character, is a comment and is ignored.  Note that this is
73              rather unconventional, because a comment can actually be in  the
74              middle  of what you might consider a token.  Note also that this
75              means if you have a comment right before the raster, the newline
76              at  the  end  of  the  comment  is not sufficient to delimit the
77              raster.
78
79
80
81       All characters referred to herein  are  encoded  in  ASCII.   "newline"
82       refers  to  the  character known in ASCII as Line Feed or LF.  A "white
83       space" character is space, CR, LF, TAB, VT, or FF (I.e. what  the  ANSI
84       standard C isspace() function calls white space).
85
86
87
88   Plain PBM
89       There is actually another version of the PBM format, even more simplis‐
90       tic, more lavishly wasteful of space than PBM, called Plain PBM.  Plain
91       PBM actually came first, but even its inventor couldn't stand its reck‐
92       lessly squanderous use of resources after a while and switched to  what
93       we  now  know as the regular PBM format.  But Plain PBM is so redundant
94       -- so overstated -- that it's virtually impossible to break.   You  can
95       send  it  through  the most liberal mail system (which was the original
96       purpose of the PBM format) and it will arrive still readable.  You  can
97       flip  a  dozen  random bits and easily piece back together the original
98       image.  And we hardly need to define the format here, because  you  can
99       decode it by inspection.
100
101       Netpbm  programs  generate  Raw  PBM format instead of Plain PBM by de‐
102       fault, but the common option ⟨index.html#commonoptions⟩  -plain chooses
103       Plain PBM.
104
105       The difference is:
106
107
108
109
110              There is exactly one image in a file.
111
112
113
114              The "magic number" is "P1" instead of "P4".
115
116
117
118              Each  pixel  in  the  raster is represented by a byte containing
119              ASCII '1' or '0', representing  black  and  white  respectively.
120              There are no fill bits at the end of a row.
121
122
123
124              White space in the raster section is ignored.
125
126
127
128              You  can  put  any  junk you want after the raster, if it starts
129              with a white space character.
130
131
132
133              No line should be longer than 70 characters.
134
135
136              Here is an example of a small image in the plain PBM format.
137              P1
138              # feep.pbm
139              24 7
140              0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
141              0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0
142              0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0
143              0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 1 0
144              0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0
145              0 1 0 0 0 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 0 0 0 0
146              0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
147
148
149       There is a newline character at the end of each of these lines.
150
151       You can generate the Plain PBM  format  from  the  regular  PBM  format
152       (first image in the file only) with the pnmtoplainpnm program.
153
154       Programs  that  read  this format should be as lenient as possible, ac‐
155       cepting anything that looks remotely like a bitmap.
156
157
158

INTERNET MEDIA TYPE

160       No Internet Media Type (aka MIME type, content type) for PBM  has  been
161       registered  with IANA, but the value image/x-portable-bitmap is conven‐
162       tional.
163
164       Note that the PNM Internet Media Type image/x-portable-anymap also  ap‐
165       plies.
166
167
168

FILE NAME

170       There are no requirements on the name of a PBM file, but the convention
171       is to use the suffix ".pbm".  "pnm" is  also  conventional,  for  cases
172       where  distinguishing  between  the particular subformats of PNM is not
173       convenient.
174
175
176

COMPATIBILITY

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

SEE ALSO

184       libnetpbm(1), pnm(1), pgm(1), ppm(1),  pam(1),  programs  that  process
185       PBM(1)
186

DOCUMENT SOURCE

188       This  manual  page was generated by the Netpbm tool 'makeman' from HTML
189       source.  The master documentation is at
190
191              http://netpbm.sourceforge.net/doc/pbm.html
192
193netpbm documentation           27 November 2013              The PBM Format(5)
Impressum