cjpeg(1) UNIX System V cjpeg(1)
NAME
cjpeg, djpeg - JPEG conversion utilities
SYNOPSIS
There are two programs, cjpeg to compress an image file into JPEG format,
and djpeg to decompress.
cjpeg [switches] [imagefile] >jpegfile
djpeg [switches] [jpegfile] >imagefile
DESCRIPTION
The programs read the specified input file, or standard input if none is
named. They always write to standard output (with trace/error messages
to standard error). These conventions are handy for piping images
between programs.
Currently supported image file formats include raw-format PPM, raw-format
PGM (for monochrome images), and GIF. cjpeg recognizes the input image
format automatically, but you have to tell djpeg which format to
generate.
The only JPEG file format currently supported is a raw JPEG data stream.
Unless modified, the programs use the JFIF conventions for variables left
unspecified by the JPEG standard. (In particular, cjpeg generates a JFIF
APP0 marker.) Support for the JPEG-in-TIFF format will probably be added
at some future date.
COMMAND LINE OPTIONS
The command line switches for cjpeg are:
-I Generate noninterleaved JPEG file (not yet supported).
-Q quality Scale quantization tables to adjust quality.
Quality is 0 (worst) to 100 (best); default is 75.
(See below for more info.)
-a Use arithmetic coding rather than Huffman coding.
(Not currently supported, see LEGAL ISSUES.)
-o Perform optimization of entropy encoding parameters.
Without this, default Huffman or arithmetic
parameters are used. -o makes the JPEG file a tad
smaller, but compression uses much more memory.
Image quality is unaffected by -o.
-d Enable debug printout. More -d's give more printout.
Typically you'd use -Q settings of 50 or 75 or so. -Q 100 will generate
a quantization table of all 1's, meaning no quantization loss; then any
differences between input and output images are due to subsampling or to
10/89 Page 1
cjpeg(1) UNIX System V cjpeg(1)
roundoff error in the DCT or colorspace-conversion steps. -Q values
below 50 may be useful for making real small, low-quality images. Try -Q
2 (or so) for some amusing Cubist effects. (Note that -Q values below
about 25 generate 2-byte quantization tables, which are not decodable by
pure baseline JPEG decoders. cjpeg emits a warning message when you give
such a -Q value.)
The command line switches for djpeg are:
-G Select GIF output format (implies -q, with default
of 256 colors).
-b Perform cross-block smoothing. This is quite
memory-intensive and only seems to improve the image
at very low quality settings (-Q 10 to 20 or so).
-g Force gray-scale output even if input is color.
-q N Quantize to N colors.
-D Use Floyd-Steinberg dithering in color quantization.
-2 Use two-pass color quantization (not yet supported).
-d Enable debug printout. More -d's give more printout.
Color quantization currently uses a rather shoddy algorithm (although
it's not so horrible when dithered). Because of this, the GIF output
mode is not recommended in the current release, except for gray-scale
output. You can get better results by applying ppmquant to the
unquantized (PPM) output of djpeg, then converting to GIF with ppmtogif.
We expect to provide a considerably better quantization algorithm in a
future release.
Note that djpeg *can* read noninterleaved JPEG files even though cjpeg
can't yet generate them. For most applications this is a nonissue, since
hardly anybody seems to be using noninterleaved format.
On a non-virtual-memory machine, you may run out of memory if you use -I
or -o in cjpeg, or -q ... -2 in djpeg, or try to read an interlaced GIF
file. This will be addressed eventually by replacing jvirtmem.c with
something that uses temporary files for large images (see TO DO).
Page 2 10/89