shun-iwasawa 82a8f5
.TH DJPEG 1 "4 November 2020"
kusano 7d535a
.SH NAME
kusano 7d535a
djpeg \- decompress a JPEG file to an image file
kusano 7d535a
.SH SYNOPSIS
kusano 7d535a
.B djpeg
kusano 7d535a
[
kusano 7d535a
.I options
kusano 7d535a
]
kusano 7d535a
[
kusano 7d535a
.I filename
kusano 7d535a
]
kusano 7d535a
.LP
kusano 7d535a
.SH DESCRIPTION
kusano 7d535a
.LP
kusano 7d535a
.B djpeg
kusano 7d535a
decompresses the named JPEG file, or the standard input if no file is named,
kusano 7d535a
and produces an image file on the standard output.  PBMPLUS (PPM/PGM), BMP,
kusano 7d535a
GIF, Targa, or RLE (Utah Raster Toolkit) output format can be selected.
kusano 7d535a
(RLE is supported only if the URT library is available.)
kusano 7d535a
.SH OPTIONS
kusano 7d535a
All switch names may be abbreviated; for example,
kusano 7d535a
.B \-grayscale
kusano 7d535a
may be written
kusano 7d535a
.B \-gray
kusano 7d535a
or
kusano 7d535a
.BR \-gr .
kusano 7d535a
Most of the "basic" switches can be abbreviated to as little as one letter.
kusano 7d535a
Upper and lower case are equivalent (thus
kusano 7d535a
.B \-BMP
kusano 7d535a
is the same as
kusano 7d535a
.BR \-bmp ).
kusano 7d535a
British spellings are also accepted (e.g.,
kusano 7d535a
.BR \-greyscale ),
kusano 7d535a
though for brevity these are not mentioned below.
kusano 7d535a
.PP
kusano 7d535a
The basic switches are:
kusano 7d535a
.TP
kusano 7d535a
.BI \-colors " N"
kusano 7d535a
Reduce image to at most N colors.  This reduces the number of colors used in
kusano 7d535a
the output image, so that it can be displayed on a colormapped display or
kusano 7d535a
stored in a colormapped file format.  For example, if you have an 8-bit
kusano 7d535a
display, you'd need to reduce to 256 or fewer colors.
kusano 7d535a
.TP
kusano 7d535a
.BI \-quantize " N"
kusano 7d535a
Same as
kusano 7d535a
.BR \-colors .
kusano 7d535a
.B \-colors
kusano 7d535a
is the recommended name,
kusano 7d535a
.B \-quantize
kusano 7d535a
is provided only for backwards compatibility.
kusano 7d535a
.TP
kusano 7d535a
.B \-fast
kusano 7d535a
Select recommended processing options for fast, low quality output.  (The
kusano 7d535a
default options are chosen for highest quality output.)  Currently, this is
kusano 7d535a
equivalent to \fB\-dct fast \-nosmooth \-onepass \-dither ordered\fR.
kusano 7d535a
.TP
kusano 7d535a
.B \-grayscale
shun-iwasawa 82a8f5
Force grayscale output even if JPEG file is color.  Useful for viewing on
kusano 7d535a
monochrome displays; also,
kusano 7d535a
.B djpeg
kusano 7d535a
runs noticeably faster in this mode.
kusano 7d535a
.TP
shun-iwasawa 82a8f5
.B \-rgb
shun-iwasawa 82a8f5
Force RGB output even if JPEG file is grayscale.
shun-iwasawa 82a8f5
.TP
kusano 7d535a
.BI \-scale " M/N"
shun-iwasawa 82a8f5
Scale the output image by a factor M/N.  Currently the scale factor must be
shun-iwasawa 82a8f5
M/8, where M is an integer between 1 and 16 inclusive, or any reduced fraction
shun-iwasawa 82a8f5
thereof (such as 1/2, 3/4, etc.)  Scaling is handy if the image is larger than
shun-iwasawa 82a8f5
your screen; also,
kusano 7d535a
.B djpeg
kusano 7d535a
runs much faster when scaling down the output.
kusano 7d535a
.TP
kusano 7d535a
.B \-bmp
kusano 7d535a
Select BMP output format (Windows flavor).  8-bit colormapped format is
kusano 7d535a
emitted if
kusano 7d535a
.B \-colors
kusano 7d535a
or
kusano 7d535a
.B \-grayscale
shun-iwasawa 82a8f5
is specified, or if the JPEG file is grayscale; otherwise, 24-bit full-color
kusano 7d535a
format is emitted.
kusano 7d535a
.TP
kusano 7d535a
.B \-gif
kusano 7d535a
Select GIF output format.  Since GIF does not support more than 256 colors,
kusano 7d535a
.B \-colors 256
kusano 7d535a
is assumed (unless you specify a smaller number of colors).
kusano 7d535a
.TP
kusano 7d535a
.B \-os2
kusano 7d535a
Select BMP output format (OS/2 1.x flavor).  8-bit colormapped format is
kusano 7d535a
emitted if
kusano 7d535a
.B \-colors
kusano 7d535a
or
kusano 7d535a
.B \-grayscale
shun-iwasawa 82a8f5
is specified, or if the JPEG file is grayscale; otherwise, 24-bit full-color
kusano 7d535a
format is emitted.
kusano 7d535a
.TP
kusano 7d535a
.B \-pnm
kusano 7d535a
Select PBMPLUS (PPM/PGM) output format (this is the default format).
shun-iwasawa 82a8f5
PGM is emitted if the JPEG file is grayscale or if
kusano 7d535a
.B \-grayscale
kusano 7d535a
is specified; otherwise PPM is emitted.
kusano 7d535a
.TP
kusano 7d535a
.B \-rle
kusano 7d535a
Select RLE output format.  (Requires URT library.)
kusano 7d535a
.TP
kusano 7d535a
.B \-targa
shun-iwasawa 82a8f5
Select Targa output format.  Grayscale format is emitted if the JPEG file is
shun-iwasawa 82a8f5
grayscale or if
kusano 7d535a
.B \-grayscale
kusano 7d535a
is specified; otherwise, colormapped format is emitted if
kusano 7d535a
.B \-colors
kusano 7d535a
is specified; otherwise, 24-bit full-color format is emitted.
kusano 7d535a
.PP
kusano 7d535a
Switches for advanced users:
kusano 7d535a
.TP
kusano 7d535a
.B \-dct int
shun-iwasawa 82a8f5
Use accurate integer DCT method (default).
kusano 7d535a
.TP
kusano 7d535a
.B \-dct fast
shun-iwasawa 82a8f5
Use less accurate integer DCT method [legacy feature].
shun-iwasawa 82a8f5
When the Independent JPEG Group's software was first released in 1991, the
shun-iwasawa 82a8f5
decompression time for a 1-megapixel JPEG image on a mainstream PC was measured
shun-iwasawa 82a8f5
in minutes.  Thus, the \fBfast\fR integer DCT algorithm provided noticeable
shun-iwasawa 82a8f5
performance benefits.  On modern CPUs running libjpeg-turbo, however, the
shun-iwasawa 82a8f5
decompression time for a 1-megapixel JPEG image is measured in milliseconds,
shun-iwasawa 82a8f5
and thus the performance benefits of the \fBfast\fR algorithm are much less
shun-iwasawa 82a8f5
noticeable.  On modern x86/x86-64 CPUs that support AVX2 instructions, the
shun-iwasawa 82a8f5
\fBfast\fR and \fBint\fR methods have similar performance.  On other types of
shun-iwasawa 82a8f5
CPUs, the \fBfast\fR method is generally about 5-15% faster than the \fBint\fR
shun-iwasawa 82a8f5
method.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
If the JPEG image was compressed using a quality level of 85 or below, then
shun-iwasawa 82a8f5
there should be little or no perceptible quality difference between the two
shun-iwasawa 82a8f5
algorithms.  When decompressing images that were compressed using quality
shun-iwasawa 82a8f5
levels above 85, however, the difference between the \fBfast\fR and \fBint\fR
shun-iwasawa 82a8f5
methods becomes more pronounced.  With images compressed using quality=97, for
shun-iwasawa 82a8f5
instance, the \fBfast\fR method incurs generally about a 4-6 dB loss in PSNR
shun-iwasawa 82a8f5
relative to the \fBint\fR method, but this can be larger for some images.  If
shun-iwasawa 82a8f5
you can avoid it, do not use the \fBfast\fR method when decompressing images
shun-iwasawa 82a8f5
that were compressed using quality levels above 97.  The algorithm often
shun-iwasawa 82a8f5
degenerates for such images and can actually produce a more lossy output image
shun-iwasawa 82a8f5
than if the JPEG image had been compressed using lower quality levels.
kusano 7d535a
.TP
kusano 7d535a
.B \-dct float
shun-iwasawa 82a8f5
Use floating-point DCT method [legacy feature].
shun-iwasawa 82a8f5
The \fBfloat\fR method does not produce significantly more accurate results
shun-iwasawa 82a8f5
than the \fBint\fR method, and it is much slower.  The \fBfloat\fR method may
shun-iwasawa 82a8f5
also give different results on different machines due to varying roundoff
shun-iwasawa 82a8f5
behavior, whereas the integer methods should give the same results on all
shun-iwasawa 82a8f5
machines.
kusano 7d535a
.TP
kusano 7d535a
.B \-dither fs
kusano 7d535a
Use Floyd-Steinberg dithering in color quantization.
kusano 7d535a
.TP
kusano 7d535a
.B \-dither ordered
kusano 7d535a
Use ordered dithering in color quantization.
kusano 7d535a
.TP
kusano 7d535a
.B \-dither none
kusano 7d535a
Do not use dithering in color quantization.
kusano 7d535a
By default, Floyd-Steinberg dithering is applied when quantizing colors; this
kusano 7d535a
is slow but usually produces the best results.  Ordered dither is a compromise
kusano 7d535a
between speed and quality; no dithering is fast but usually looks awful.  Note
kusano 7d535a
that these switches have no effect unless color quantization is being done.
kusano 7d535a
Ordered dither is only available in
kusano 7d535a
.B \-onepass
kusano 7d535a
mode.
kusano 7d535a
.TP
shun-iwasawa 82a8f5
.BI \-icc " file"
shun-iwasawa 82a8f5
Extract ICC color management profile to the specified file.
shun-iwasawa 82a8f5
.TP
kusano 7d535a
.BI \-map " file"
kusano 7d535a
Quantize to the colors used in the specified image file.  This is useful for
kusano 7d535a
producing multiple files with identical color maps, or for forcing a
kusano 7d535a
predefined set of colors to be used.  The
kusano 7d535a
.I file
kusano 7d535a
must be a GIF or PPM file. This option overrides
kusano 7d535a
.B \-colors
kusano 7d535a
and
kusano 7d535a
.BR \-onepass .
kusano 7d535a
.TP
kusano 7d535a
.B \-nosmooth
shun-iwasawa 82a8f5
Use a faster, lower-quality upsampling routine.
kusano 7d535a
.TP
kusano 7d535a
.B \-onepass
kusano 7d535a
Use one-pass instead of two-pass color quantization.  The one-pass method is
kusano 7d535a
faster and needs less memory, but it produces a lower-quality image.
kusano 7d535a
.B \-onepass
kusano 7d535a
is ignored unless you also say
kusano 7d535a
.B \-colors
kusano 7d535a
.IR N .
shun-iwasawa 82a8f5
Also, the one-pass method is always used for grayscale output (the two-pass
kusano 7d535a
method is no improvement then).
kusano 7d535a
.TP
kusano 7d535a
.BI \-maxmemory " N"
kusano 7d535a
Set limit for amount of memory to use in processing large images.  Value is
kusano 7d535a
in thousands of bytes, or millions of bytes if "M" is attached to the
kusano 7d535a
number.  For example,
kusano 7d535a
.B \-max 4m
shun-iwasawa 82a8f5
selects 4000000 bytes.  If more space is needed, an error will occur.
kusano 7d535a
.TP
kusano 7d535a
.BI \-outfile " name"
kusano 7d535a
Send output image to the named file, not to standard output.
kusano 7d535a
.TP
shun-iwasawa 82a8f5
.BI \-memsrc
shun-iwasawa 82a8f5
Load input file into memory before decompressing.  This feature was implemented
shun-iwasawa 82a8f5
mainly as a way of testing the in-memory source manager (jpeg_mem_src().)
shun-iwasawa 82a8f5
.TP
shun-iwasawa 82a8f5
.BI \-skip " Y0,Y1"
shun-iwasawa 82a8f5
Decompress all rows of the JPEG image except those between Y0 and Y1
shun-iwasawa 82a8f5
(inclusive.)  Note that if decompression scaling is being used, then Y0 and Y1
shun-iwasawa 82a8f5
are relative to the scaled image dimensions.
shun-iwasawa 82a8f5
.TP
shun-iwasawa 82a8f5
.BI \-crop " WxH+X+Y"
shun-iwasawa 82a8f5
Decompress only a rectangular subregion of the image, starting at point X,Y
shun-iwasawa 82a8f5
with width W and height H.  If necessary, X will be shifted left to the nearest
shun-iwasawa 82a8f5
iMCU boundary, and the width will be increased accordingly.  Note that if
shun-iwasawa 82a8f5
decompression scaling is being used, then X, Y, W, and H are relative to the
shun-iwasawa 82a8f5
scaled image dimensions.  Currently this option only works with the
shun-iwasawa 82a8f5
PBMPLUS (PPM/PGM), GIF, and Targa output formats.
shun-iwasawa 82a8f5
.TP
kusano 7d535a
.B \-verbose
kusano 7d535a
Enable debug printout.  More
kusano 7d535a
.BR \-v 's
kusano 7d535a
give more output.  Also, version information is printed at startup.
kusano 7d535a
.TP
kusano 7d535a
.B \-debug
kusano 7d535a
Same as
kusano 7d535a
.BR \-verbose .
shun-iwasawa 82a8f5
.TP
shun-iwasawa 82a8f5
.B \-version
shun-iwasawa 82a8f5
Print version information and exit.
kusano 7d535a
.SH EXAMPLES
kusano 7d535a
.LP
kusano 7d535a
This example decompresses the JPEG file foo.jpg, quantizes it to
kusano 7d535a
256 colors, and saves the output in 8-bit BMP format in foo.bmp:
kusano 7d535a
.IP
kusano 7d535a
.B djpeg \-colors 256 \-bmp
kusano 7d535a
.I foo.jpg
kusano 7d535a
.B >
kusano 7d535a
.I foo.bmp
kusano 7d535a
.SH HINTS
kusano 7d535a
To get a quick preview of an image, use the
kusano 7d535a
.B \-grayscale
kusano 7d535a
and/or
kusano 7d535a
.B \-scale
kusano 7d535a
switches.
kusano 7d535a
.B \-grayscale \-scale 1/8
kusano 7d535a
is the fastest case.
kusano 7d535a
.PP
kusano 7d535a
Several options are available that trade off image quality to gain speed.
kusano 7d535a
.B \-fast
kusano 7d535a
turns on the recommended settings.
kusano 7d535a
.PP
kusano 7d535a
.B \-dct fast
kusano 7d535a
and/or
kusano 7d535a
.B \-nosmooth
kusano 7d535a
gain speed at a small sacrifice in quality.
kusano 7d535a
When producing a color-quantized image,
kusano 7d535a
.B \-onepass \-dither ordered
kusano 7d535a
is fast but much lower quality than the default behavior.
kusano 7d535a
.B \-dither none
kusano 7d535a
may give acceptable results in two-pass mode, but is seldom tolerable in
kusano 7d535a
one-pass mode.
kusano 7d535a
.SH ENVIRONMENT
kusano 7d535a
.TP
kusano 7d535a
.B JPEGMEM
kusano 7d535a
If this environment variable is set, its value is the default memory limit.
kusano 7d535a
The value is specified as described for the
kusano 7d535a
.B \-maxmemory
kusano 7d535a
switch.
kusano 7d535a
.B JPEGMEM
kusano 7d535a
overrides the default value specified when the program was compiled, and
kusano 7d535a
itself is overridden by an explicit
kusano 7d535a
.BR \-maxmemory .
kusano 7d535a
.SH SEE ALSO
kusano 7d535a
.BR cjpeg (1),
kusano 7d535a
.BR jpegtran (1),
kusano 7d535a
.BR rdjpgcom (1),
kusano 7d535a
.BR wrjpgcom (1)
kusano 7d535a
.br
kusano 7d535a
.BR ppm (5),
kusano 7d535a
.BR pgm (5)
kusano 7d535a
.br
kusano 7d535a
Wallace, Gregory K.  "The JPEG Still Picture Compression Standard",
kusano 7d535a
Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44.
kusano 7d535a
.SH AUTHOR
kusano 7d535a
Independent JPEG Group
shun-iwasawa 82a8f5
.PP
shun-iwasawa 82a8f5
This file was modified by The libjpeg-turbo Project to include only information
shun-iwasawa 82a8f5
relevant to libjpeg-turbo, to wordsmith certain sections, and to describe
shun-iwasawa 82a8f5
features not present in libjpeg.
shun-iwasawa 82a8f5
.SH ISSUES
shun-iwasawa 82a8f5
Support for compressed GIF output files was removed in djpeg v6b due to
shun-iwasawa 82a8f5
concerns over the Unisys LZW patent.  Although this patent expired in 2006,
shun-iwasawa 82a8f5
djpeg still lacks compressed GIF support, for these historical reasons.
shun-iwasawa 82a8f5
(Conversion of JPEG files to GIF is usually a bad idea anyway, since GIF is a
shun-iwasawa 82a8f5
256-color format.)  The uncompressed GIF files that djpeg generates are larger
shun-iwasawa 82a8f5
than they should be, but they are readable by standard GIF decoders.