PBM Files
PBM is the portable bitmap format, a lowest common denominator
monochrome file format. It was originally designed to make it reasonable
to mail bitmaps between different types of machines. Now it serves as
the common language of a large family of bitmap conversion filters.
The definition is as follows:
-
A "magic number" for identifying the file type. A PBM file's magic
number is the two characters "P1".
-
Whitespace (blanks, TABs, CRs, LFs).
-
A width, formatted as ASCII characters in decimal.
-
Whitespace.
-
A height, again in ASCII decimal.
-
Whitespace.
-
Width * height bits, each either '1' or '0', starting at the top-left
corner of the bitmap, proceeding in normal English reading order.
The character '1' means black, '0' means white.
Whitespace in the bits section is ignored.
Characters from a "#" to the next end-of-line are ignored (comments).
No line should be longer than 70 characters.
There is also a variant on the format, available by setting the RAWBITS
option at compile time. This variant is different in the following ways:
-
The "magic number" is "P4" instead of "P1".
-
The bits are stored eight per byte, high bit first low bit last.
-
No whitespace is allowed in the bits section, and only a single
character of whitespace (typically a newline) is allowed after the
height.
The files are eight times smaller and many times faster to read and write.
EXAMPLE:
P1
# feep.pbm
24 7
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0
0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0
0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 1 0
0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0
0 1 0 0 0 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
PBM files are:
-
ASCII or BINARY
-
black and white
-
2D
-
No compression
-
1 image
-
Reference:
-
Programs to create a PBM file include:
Programs to view a PBM file include:
-
The AVS module read_any_image can read a PBM file;
-
GIMP
-
The
ImageVision
program imgview can display a PBM file.
-
XV
Routines to read or write a PBM file:
Programs to convert a PBM file to another format:
-
GIMP can read a PBM file
and write out a copy in a variety of formats.
-
PBMTOASCII can read a PBM file and write out it out as ASCII graphics.
-
XV can read a PBM file
and write out a copy in BMP, FIT, GIF, JPG, PGM/PM, RGB or TIF
format.
Programs to convert a file to PBM format:
-
GIMP can read a file in a
variety of formats, and write it out as a PBM file.
-
XV can read a file in a
BMP, FIT, GIF, JPG, PGM/PPM, RGB or TIF format, and write it out
as a PBM file.
Files you may copy:
Back to the data home page.
Last revised on 10 May 2002.