Other documentation files in the distribution are:
User documentation:
install.doc Ho w to configure and install the IJG
sof tware.
usage.doc Usage instructions for cjpeg , djpeg,
jpegtran, rdjpgcom, and wrjpgcom.
*.1 Unix-style man pages for programs
(same info as usage.doc).
wizard.doc Advanced usage instructions for JPEG
wizards only .
c hange.log V ersion-to-version c hange highlights.
Programmer and internal documentation:
libjpeg.doc How to use the JPEG library in your o wn
programs.
example.c Sample code for calling the JPEG library .
struct ure.doc O v erview of the JPEG librar y’ s internal
struct ure.
filelist.doc Road map of IJG files.
coderules.doc Coding st yle rules --- please read if you
contribute code.
Please read at least the files inst all.doc and usage.doc. Useful
information can also be f ound in the JPEG F AQ (Frequently Asked
Questions) article. See ARCHIVE LOCA TIONS below to find out
where to obtain the F A Q article.
If you want to underst and how the JPEG code works, we suggest
reading one or more of the REFERENCES, then looking at the
documentation files (in roughly the order listed) bef ore diving into
the code.
O VERVIEW
This pac kage contains C sof tware to implement JPEG image
compression and decompression. JPEG (pronounced “jay-peg”)
is a standardized compression method for full-color and gray-scale
images. JPEG is intended for compressing “real-w orld” scenes; line
drawings, cartoons and other non-realistic images are not its strong
suit. JPEG is lossy , meaning that the output image is not e xactly
identical to the input image. Hence you must not use JPEG if you
have to ha ve identical output bits. Howe ver , on typical photographic
images, v ery good compression le vels can be obtained with no
visible change, and remarkably high compression levels are possible
if you can tolerate a lo w -quality image. F or more details, see the
references, or just e xperiment with various compression set tings.
This software implements JPEG baseline, extended-sequential, and
progressive
compression processes. P rovision is made for supporting all variants
of these
processes, although some uncommon parameter settings aren ’t
implemented yet.
For legal reasons, we are not distributing code for the arithmetic-
coding
variants of JPEG; see LEGAL ISSUES. W e have made no provision
for supporting
the hierarc hical or lossless processes defined in the standard.
We provide a set of librar y routines f or reading and writing JPEG
image files, plus two sample applications “cjpeg” and “djpeg” , whic h
use the library to perform conv ersion between JPEG and some other
popular image file formats.
The library is intended to be reused in other applications.
In order to support file conversion and viewing software, we have
included considerable functionality bey ond the bare JPEG coding/
decoding capability; for example, the color quantization modules
are not strictly part of JPEG decoding, but they are essential for
output to colormapped file formats or colormapped displays. These
extra functions can be compiled out of the librar y if not required for
a particular application. W e ha ve also included “jpegtran ” , a utility
for lossless transcoding bet ween diff erent JPEG processes, and
“rdjpgcom” and “wrjpgcom” , t wo simple applications f or inserting
and extracting text ual comments in JFIF files.
The emphasis in designing this software has been on achieving
portability and fl exibility , while also making it fast enough to be
useful. In particular , the software is not intended to be read as a
tutorial on JPEG. (See the REFERENCES section f or introductor y
material.) Rather , it is intended to be reliable, portable, industrial-
strength code. W e do not claim to have achie ved that goal in every
aspect of the sof tware, but we striv e for it.
We w elcome the use of this sof tware as a component of commercial
products.
No ro yalty is required, but we do ask for an ac knowledgement in
product documentation, as described under LEGAL ISSUES.
LEGAL ISSUES
In plain English:
1 . We don ’t promise that this sof tware works. (But if you find any
bugs, please let us know!)
2. Y ou can use this sof tware for whatev er you want. Y ou don’ t have
to pay us.
3. Y ou may not pretend that y ou wrote this sof tware. If you use
it in a program, you must acknowledge somewhere in your
documentation that you’v e used the IJG code.
In legalese:
The authors mak e NO W ARRANTY or representation, either express
or implied, with respect to this software, its quality , accuracy ,
merc hantability, or fitness for a particular purpose. T his software is
provided “ A S IS” , and you, its user, assume the entire risk as to its
quality and accuracy .
This sof tware is cop yright (C) 1 991 -1 998, Thomas G. Lane.
All Rights Reserved except as specifi ed belo w .
P ermission is hereb y granted to use, cop y , modify , and distribute this
sof tware (or portions thereof) for any purpose, without fee, subject
to these conditions:
(1) If any part of the source code for this sof tware is distributed,
then this README file must be included, with this copyright
and no-w arranty notice unaltered; and any additions, deletions,
or changes to the original files must be clearly indicated in
accompanying documentation.
(2) If only executable code is distributed, then the accompanying
documentation must st ate that “this sof tware is based in part on
the work of the Independent JPEG Group” .
(3) Permission for use of this sof tware is granted only if the user
accepts full responsibility for any undesirable consequences; the
authors accept NO LIABILITY for damages of an y kind.
These conditions apply to any sof tware deriv ed from or based on the
IJG code, not just to the unmodifi ed librar y . If y ou use our work, you
ought to ac knowledge us.
P ermission is NO T granted for the use of any IJG author’ s name or
company name in advertising or publicity relating to this software or
products derived from it. This software may be referred to only as
“the Independent JPEG Group’ s sof tw are ” .
We specifically permit and encourage the use of this sof tware as the
basis of commercial products, provided that all warranty or liability
claims are assumed by the product vendor .
ansi2knr .c is included in this distribution by permission of L. Peter
Deutsc h, sole proprietor of its copyright holder , Aladdin Enterprises
of Menlo Park, CA.
ansi2knr .c is NO T co vered by the above cop yright and conditions,
but instead b y the usual distribution terms of the F ree Sof tware
Foundation; principally , that you must include source code if you
redistribute it. (See the file ansi2knr .c f or full details.) Howev er ,
since ansi2knr .c is not needed as part of any program generated
from the IJG code, this does not limit you more than the foregoing
paragraphs do.
The Unix configuration script “configure ” was produced with GNU
Autoconf .
It is cop yright b y the F ree Software F oundation but is freely
distributable.
The same holds for its supporting scripts (config.guess, config.sub,
ltconfig, ltmain.sh). Another support script, install-sh, is copyright by
M.I.T . but is also freely distributable.
It appears that the arithmetic coding option of the JPEG spec is
covered by patents o wned b y IBM, A T&T , and Mitsubishi. Hence
arithmetic coding cannot legally be used without obtaining one or
more licenses. For this reason, support f or arithmetic coding has
been removed from the free JPEG sof tw are.
(Since arithmetic coding provides only a marginal gain over
the unpatented Huffman mode, it is unlik ely that ver y many
implementations will support it.)
So far as we are a ware, there are no patent restrictions on the
remaining code.
The IJG distribution formerly included code to read and write GIF
files.
T o a v oid entanglement with the Unisys LZW patent, GIF reading
support has been removed altogether , and the GIF writer has been
simplified to produce “uncompressed GIFs” . T his tec hnique does not
use the LZW algorithm; the resulting GIF files are larger than usual,
but are readable by all standard GIF decoders.
We are required to state that
“The Graphics Interc hange F ormat(c) is the Copyright property of
CompuServe Incorporated. GIF(sm) is a Service Mark property of
CompuServe Incorporated. ”
REFERENCES
We highly recommend reading one or more of these references
before trying to understand the innards of the JPEG software.
The best short technical introduction to the JPEG compression
algorithm is
Wallace, Gregor y K. “T he JPEG Still Pict ure Compression
Standard” , Communications of the ACM, April 1991 (vol. 34 no.
4), pp. 30-44.
(Adjacent articles in that issue discuss MPEG motion pict ure
compression, applications of JPEG, and related topics.) If you don ’t
have the CA CM issue handy, a P ostScript file cont aining a re vised
version of W allace’ s article is av ailable at f tp://f tp.uu.net/graphics/
jpeg/wallace.ps.gz. The file (act ually a preprint for an article that
appeared in IEEE T rans. Consumer Electronics) omits the sample
images that appeared in CA CM, but it includes corrections and some
added material. Note: the Wallace article is cop yright A CM and IEEE,
and it may not be used for commercial purposes.
A somewhat less tec hnical, more leisurely introduction to JPEG can
be found in “The Data Compression Book” b y Mark Nelson and J ean-
loup Gailly , published by M&T B ooks (New Y ork), 2nd ed. 1 996, ISBN
1 -55851 -434-1 . T his book provides good e xplanations and example C
code for a multitude of compression methods including JPEG. It is
an ex cellent source if you are comfortable reading C code but don ’t
know muc h about data compression in general. The book’ s JPEG
sample code is far from industrial-strength, but when you are ready
to look at a full implementation, you’v e got one here...
The best full description of JPEG is the textbook “JPEG Still Image
Data Compression Standard” by William B. P ennebak er and Joan
L. Mitc hell, published by V an Nostrand Reinhold, 1993, ISBN 0-442-
0 1 272-1 . P rice US$59.95, 638 pp.
The book includes the complete text of the ISO JPEG standards (DIS
1 091 8-1 and draf t DIS 1 091 8-2).
This is by f ar the most complete e xposition of JPEG in e xistence, and
we highly recommend it.
The JPEG standard itself is not a vailable electronically; you must
order a paper copy through ISO or ITU. (Unless you feel a need to
own a certified official copy , we recommend buying the P ennebaker
and Mitchell book instead; it’ s much c heaper and includes a great
deal of useful explanatory material.)
In the USA, copies of the st andard may be ordered from ANSI Sales
at (21 2) 642-4900, or from Global Engineering Documents at (800)
854-71 79. (ANSI doesn’t take credit card orders, but Global does.)
It’ s not c heap: as of 1 992, ANSI was c harging $95 for P art 1 and $47
for Part 2, plus 7% shipping/handling. The standard is divided into
two parts, Part 1 being the actual specification, while Part 2 covers
compliance testing methods. Part 1 is titled “Digit al Compression
and Coding of Continuous-tone Still Images, Part 1: Requirements
and guidelines” and has document numbers ISO/IEC IS 1091 8-
1, I TU-T T .81 . Part 2 is titled “Digit al Compression and Coding of
Continuous-tone Still Images, Part 2: Compliance testing” and has
document numbers ISO/IEC IS 1 091 8-2, ITU-T T .83.
Some extensions to the original JPEG st andard are defined in JPEG
Part 3, a new er ISO standard numbered ISO/IEC IS 1 0918-3 and ITU-
T T .84. IJG currently does not support any P art 3 extensions.
The JPEG standard does not specify all details of an interc hangeable
file format. F or the omit ted det ails we f ollow the “JFIF” conventions,
revision 1 .02. A cop y of the JFIF spec is av ailable from:
Literature Department
C-Cube Microsystems, Inc.
1 778 McCarth y Blvd.
Milpitas, CA 95035
phone (408) 944-6300, fax (408) 944-631 4
A PostScript version of this document is av ailable by FTP at ftp://f tp.
uu.net/graphics/jpeg/jfi f .ps.gz. There is also a plain te xt v ersion at
f tp://f tp.uu.net/graphics/jpeg/jfi f .txt.gz, but it is missing the figures.
The TIFF 6.0 file format specification can be obtained by FTP from
f tp://f tp.sgi.com/graphics/tif f/TIFF6.ps.gz. T he JPEG incorporation
sc heme found in the TIFF 6.0 spec of 3-June-92 has a number of
serious problems.
IJG does not recommend use of the TIFF 6.0 design (TIFF
Compression tag 6).
Instead, w e recommend the JPEG design proposed by TIFF T ec hnical
Note #2 (Compression tag 7). Copies of this Note can be obtained
from f tp.sgi.com or from ftp://f tp.uu.net/graphics/jpeg/. It is e xpected
that the next revision of the TIFF spec will replace the 6.0 JPEG
design with the Note’ s design.
Although IJG’ s own code does not support TIFF/JPEG, the free libtif f
library uses our library to implement TIFF/JPEG per the Note. libtiff
is available from f tp://f tp.sgi.com/graphics/tif f/.
ARCHIVE LOCA TIONS
The “ of ficial” arc hiv e site f or this sof tware is f tp.uu.net (Internet
address 192.48.96.9). T he most recent released version can always
be found there in director y graphics/jpeg . This particular version will
be arc hived as f tp://f tp.uu.net/graphics/jpeg/jpegsrc.v6b.tar .gz.
If you don’t hav e direct Internet access, UUNET’ s arc hives are also
available via UUCP; contact help@ uunet.uu.net for information on
retrieving files that wa y .
Numerous Internet sites maintain copies of the UUNE T files.
Howe ver , only ftp.uu.net is guaranteed to have the latest of ficial
version.
Y ou can also obtain this software in DOS-compatible “zip” arc hiv e
format from the SimT el arc hiv es (f tp://f tp.simtel.net/pub/simtelnet/
msdos/graphics/), or on CompuServe in the Graphics Support forum
(GO CIS:GRAPHSUP), library 12 “JPEG T ools” . A gain, these versions
may sometimes lag behind the f tp.uu.net release.
The JPEG F A Q (F requently Ask ed Questions) article is a useful
source of general information about JPEG. It is updated const antly
and therefore is not included in this distribution. The F A Q is posted
every two w eeks to Usenet ne wsgroups comp.graphics.misc, ne ws.
answers, and other groups.
It is a vailable on the World W ide W eb at ht tp://www .faqs.org/faqs/
jpeg-faq/ and other news.answers arc hiv e sites, including the official
news.answers arc hiv e at rtfm.mit.edu: f tp://rtfm.mit.edu/pub/usenet/
news.answers/jpeg-f aq/.
If you don’ t have Web or FTP access, send e-mail to mail-ser ver@
rtfm.mit.edu with body
send usenet/news.answers/jpeg-f aq/part1
send usenet/news.answers/jpeg-f aq/part2
RELA TED SOFTW ARE
Numerous viewing and image manipulation programs now support
JPEG. (Quite a f ew of them use this library to do so.) The JPEG F AQ
described above lists some of the more popular free and shareware
viewers, and tells where to obtain them on Internet.
If you are on a Unix mac hine, we highly recommend Jef P oskanz er’ s
free PBMPLUS sof tware, which pro vides many useful operations on
PPM-format image files. In particular , it can convert PPM images to
and from a wide range of other formats, thus making cjpeg/djpeg
considerably more useful. The latest v ersion is distributed b y the
NetPBM group, and is available from numerous sites, not ably ftp://
wuarc hive.wustl.edu/graphics/graphics/pac kages/NetPBM/.
Unfort unately PBMPLUS/NETPBM is not nearly as port able as the
IJG sof tware is; y ou are likely to hav e dif ficulty making it w ork on any
non-Unix mac hine.
A diff erent free JPEG implement ation, written by the PVRG group
at Stanford,
is available from ftp://hav efun.stanford.edu/pub/jpeg/. This program
is designed for research and experimentation rather than production
use; it is slower , harder to use, and less port able than the IJG code,
but it is easier to read and modify. Also, the PVRG code supports
lossless JPEG, whic h we do not. (On the other hand, it doesn’ t do
progressive JPEG.)
FILE FORMA T W AR S
Some JPEG programs produce files that are not compatible with our
library.
The root of the problem is that the ISO JPEG committee failed to
specify a concrete file f ormat. Some v endors “filled in the blanks” on
their own, creating proprietar y formats that no one else could read.
(For example, none of the early commercial JPEG implement ations
for the Macintosh were able to e xc hange compressed files.)
The file format we hav e adopted is called JFIF (see REFERENCES).
This format has been agreed to by a number of major commercial
JPEG vendors, and it has become the de facto standard. JFIF is a
minimal or “low end” representation.
We recommend the use of TIFF/JPEG (TIFF revision 6.0 as modified
LICENSE