Image file formats are the standards by which pictoral information is
stored in and retrieved from files.
Since images are often a bit of work to produce, and you will probably
want to keep a number of them around (for repeatable testing if nothing else)
you will need to deal with these.
Image file formats are distinct from memory or in-core formats, which are
used for handling images inside programs.
Historically, in-core formats did not exist as computers did not have
enough memory to hold an entire image.
These days, loading entire images into the program is standard practice,
and a number of in-core formats exist. One of these is defined by
RN's ipp package, and there are others as well.
There are a lot of different image file formats, developed for
different purposes, and with different attributes.
Common ones include tiff, jpeg, png, gif, pgm, ppm, matlab matrices,
and postscript files.
These all have their own advantages and disadvantages.
Most allow color (tiff, jpeg, png, gif, ppm, postscript);
some may be compressed in a complicated and possibly lossy manner
(gif, jpeg are (usually) lossy, png is lossless but conpressed, and
tiff supports several compression schemes, but is often used for
uncompressed images); some are terribly
inefficient (matlab, postscript); and some are proprietary (gif, postscript).
My up front recommendation for this course is to use the tiff format as
much as possible as it is relatively simple, allows color,
is not propriatary, and is in common use.
The historical department image file format, which a lot of old software
runs on is known as iff, and it is convenient to designate
iff image file with the .iff suffix (as in picture.iff).
It is primarily a gray-scale format (though with a variable number of bits).
There is presently no department standard for representing color images
with iff, though several people have hacked together their own
representations (e.g., using three separate images, or 24 bit pixels
which are then pulled apart). One of these is associated with the nelson
image processing library (ipp), though you will probably never
need to use it.
The main problem with iff is that no one else in the world uses it, so
it is probably best to use some other format as much as possible.
There are programs for converting iff to and from other formats,
for example iff2ps, iff2pgm and RN's convert_format program.
The basic iff format is in /usr/src/vision/iff/bin/image.h,v.
One very useful program is xv, which take images in
various formats, including tiff, pgm, jpeg, ps, and oldstyle gif,
and allows you to display them and
do other operations (e.g find the value at a point, specify a window
using a mouse, remap colors, convert to new formats, etc.) using an
Xv will accept old style gif images, but not newer versions due to
a licensing problem.
It does not recognize iff, but the program "convert_format" in my bin
converts between a limited number of formats (tiff, pgm, iff and cvl),
can be used get an iff image into a form that xv can use.
A quick way of viewing a tiff, png, jpg, pgm, iff, or cvl image is to use
the "xshow" program, also in my bin.
The dithering is not quite as good as xv if you happen to be on
an 8-bit or fewer!! display (unlikely as of 2003), but it is adequate,
and the program is a lot faster. The component routines can also be called
from inside a program by linking the ipp utility library.
List of Common Image File Formats
vision course main page
(Tagged Image Format). Default suffixes, .tif, .tiff
Nice generic, non-licensed format that can
handle anything from bitmaps to compressed color palette images (non-lossy).
This is RN's recommendation for the format to use for your image needs in
Available under linux by linking the libtiff, libjpeg, and libz libraries.
Do man libtiff for more information, or click on the above link for
One of the formats known to the nelson ipp package (uncompressed only).
Can be converted to other formats by xv or RNs imagecalc program.
One problem with tiff is that it is a bit too broad. Hardly any program
(not even xv) can handle all the ways that images might be represented,
with the result that you sometimes find yourself with a tiff file that
your application will not read. This is especially true if some compression
mode has been used.
- PNG: (Portable Network Graphics). Default suffix, .png
An extensible file format tha provides lossless, well-compressed storage
of raster images. Provides a patent-free replacement for GIF, and
also subsumes much of the useful functionality of TIFF without
all the complexity. Grayscale, color pallete, and full color (truecolor)
images are supported, with an optional alpha channel, and depths from
1-16 bits per channel.
Available under linux by linking the libpng library.
Do man (png, libpng) for additional information.
Full Specification available at
Known to the nelson ipp library.
Can be converted to other formats by xv or RNs imagecalc program.
- JPEG: (Joint Photo Experts Group). Default suffix .jpg
Standard for transmission of pictoral information.
Includes a variable lossy encoding as part of the standard, set by
a quality parameter. The loss can be set to zero, but most programs do not
use zero loss as the default, so you are likely to see some artifacts
in a random jpeg image. Compression is based on discrete cosine transform,
and is tailored so as to reduce perceptual distortion.
Available under linux by linking the libjpeg library.
Known to the nelson ipp library; writing is at default 75% quality.
xv can be used to convert to and from other formats at various quality
levels. RNs imagecalc writes at default 75% only.
- MPEG: Like JPEG only for motion images. Almost always compressed
in a lossy fashion. This is how a lot of videos are shipped around the web.
The SGI program "capture" can produce mpeg videos for you.
Unfortunately we don't seem to have a lot of software for handling mpeg at
a level where you want to write programs to process the image sequence.
- PBM, PGM, PPM, PNM: Portable (Bitmap, Graymap, Pixmap, Anymap).
Default suffixes, .pbm, .pgm, .ppm, .pnm
Set of image formats of increasing complexity - from bits to gray levels,
to pixmaps of various sorts.
PGM is a fairly popular format for gray-scale images.
Linux has C libraries for IO from most of these
formats (libpbm, libpgm, libppm).
Do man (pbm, ppm, pgm, pnm) for more information.
PGM (grayscale only) is known to the nelson ipp package.
Useful conversion programs: xv, and a whole slew of (pbm|pgm|ppm|pnm)(to|2)X
programs, where X may be a number of formats including pbm, pgm, ppm, pnm,
gif, tiff, iff, fs, lispm. Also some miscellaneous image processing
- GIF: (Graphics Interchange Format) Default suffix, .gif
Everyone's favorite for www images. Limited to 8 bit color pallette
images, and consequently not good for image processing applications.
Old format GIF87 is accepted by lots of programs. Latest version
requires licensing to use, so a lot of programs don't bother.
Since it is under some sort of IP protection, we don't have
any libraries for dealing with gif.
Nelson ipp package does NOT know about this format.
Useful conversion programs: xv, gif2tiff, giftopnm, ppmtogif.
- RGB: Default suffix, .rgb
Silicon graphics image file standard for color images.
Useful conversion programs: xv.
- RAS: Sun Raster images. Default suffix .ras
Basically an uncompressed scan-out of three
color bands. Output by some of the old ktv digitizer programs.
xv will convert to other formats.
- IFF: (Image File Format). Default suffix, .iff
Historic department standard. Nobody else uses it. We don't either anymore,
but you might find a .iff file sitting around somewhere.
Most of the software assumes 8 bit gray-scale images.
Supposedly you can define images with more bits per pixel, but the rumor is
that some of the low-level file io software will croak if you try.
RN has a color version which just concatenates the data from three
color bands - red, green, and blue.
Useful conversion programs: iff2pgm, pgm2iff, iff2ps, convert_format
(in nelson's bin).
Also a bunch of image processing programs, and C libraries for simple
- Postscript: Not really an image format, except that images can be
represented in it. Very inefficient. Gray levels are represented by decimal
or hex numerals encoded in ascii.
Useful primarily if you want to put an image into a paper or print it out.
In this case, iff2ps and xv are useful.
In Adobe's more recent pdf format, images are generally compressed,
so papers with pics are not so terribly huge.
- Matlab: You can store Matlab arrays into a file. Matlab can read them
back. I don't know if anyone else can. Very inefficient, since matlab
store images as double precision (complex) arrays.