pbm.5 revision 20781
153813Simp.Dd "September 27, 1991"
2113318Simp.Dt PBM 5
3100213Simp.Sh NAME
452506Simp.Nm pbm
552506Simp.Nd portable bitmap file format
652506Simp.Sh DESCRIPTION
752506SimpThe portable bitmap format is a lowest common denominator monochrome
852506Simpfile format.
952506SimpIt was originally designed to make it reasonable to mail bitmaps
1052506Simpbetween different types of machines using the typical stupid network
1152506Simpmailers we have today.
1252506SimpNow it serves as the common language of a large family of bitmap
1352506Simpconversion filters.
1452506SimpThe definition is as follows:
1552506Simp.Pp
1652506Simp.Bl -bullet -compact
1752506Simp.It
1852506SimpA "magic number" for identifying the file type.
1952506SimpA pbm file's magic number is the two characters "P1".
2052506Simp.It
2152506SimpWhitespace (blanks, TABs, CRs, LFs).
2252506Simp.It
2352506SimpA width, formatted as ASCII characters in decimal.
2452506Simp.It
2552506SimpWhitespace.
2652506Simp.It
2752506SimpA height, again in ASCII decimal.
2852506Simp.It
2952506SimpWhitespace.
3052506Simp.It
3152506SimpWidth * height bits, each either '1' or '0', starting at the top-left
3252506Simpcorner of the bitmap, proceeding in normal English reading order.
3352506Simp.It
3452506SimpThe character '1' means black, '0' means white.
3552506Simp.It
3652506SimpWhitespace in the bits section is ignored.
3752506Simp.It
3852506SimpCharacters from a "#" to the next end-of-line are ignored (comments).
3952506Simp.It
4052506SimpNo line should be longer than 70 characters.
4152506Simp.El
4286269Simp.Pp
4352506SimpHere is an example of a small bitmap in this format:
4452506Simp.Bd -literal
4552506SimpP1
46104854Simp# feep.pbm
4758545Simp24 7
4852506Simp0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4965039Simp0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0
5065039Simp0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0
5152506Simp0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 1 0
5252506Simp0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0
5352506Simp0 1 0 0 0 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 0 0 0 0
5452506Simp0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5552506Simp.Ed
5658545Simp.Pp
5752506SimpPrograms that read this format should be as lenient as possible,
5886455Simpaccepting anything that looks remotely like a bitmap.
5979270Simp.Pp
60107359SnonThere is also a variant on the format, available
6152506Simpby setting the RAWBITS option at compile time.  This variant is
6286269Simpdifferent in the following ways:
6386455Simp.Pp
6452506Simp.Bl -bullet -compact
6552506Simp.It
6686455SimpThe "magic number" is "P4" instead of "P1".
6758545Simp.It
68104854SimpThe bits are stored eight per byte, high bit first low bit last.
6986269Simp.It
70104854SimpNo whitespace is allowed in the bits section, and only a single character
7152506Simpof whitespace (typically a newline) is allowed after the height.
7286455Simp.It
7352506SimpThe files are eight times smaller and many times faster to read and write.
7486455Simp.El
7553813Simp.Sh AUTHOR
76100213SimpCopyright (C) 1989, 1991 by Jef Poskanzer.
7758545Simp.\" Permission to use, copy, modify, and distribute this software and its
7889945Simp.\" documentation for any purpose and without fee is hereby granted, provided
7984514Simp.\" that the above copyright notice appear in all copies and that both that
8058545Simp.\" copyright notice and this permission notice appear in supporting
8169138Speter.\" documentation.  This software is provided "as is" without express or
8252506Simp.\" implied warranty.
8358545Simp