<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
                   "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
<!-- lifted from troff+man by doclifter -->
<refentry id='djpeg1'>
<refmeta>
<refentrytitle>DJPEG</refentrytitle>
<manvolnum>1E</manvolnum>
<refmiscinfo class='date'>22 August 1997</refmiscinfo>
<refmiscinfo class='source'>IJG</refmiscinfo>
<refmiscinfo class='manual'>NFIS Reference Manual</refmiscinfo>
</refmeta>
<refnamediv id='name'>
<refname>djpeg</refname>
<refpurpose>decompress a JPEG file to an image file</refpurpose>
</refnamediv>
<!-- body begins here -->
<refsynopsisdiv id='synopsis'>
<cmdsynopsis>
  <command>djpeg</command>    
    <arg choice='opt'><replaceable>options</replaceable></arg>
    <arg choice='opt'><replaceable>filename</replaceable></arg>
    <sbr/>
</cmdsynopsis>
</refsynopsisdiv>


<refsect1 id='description'><title>DESCRIPTION</title>
<para><command>djpeg</command>
decompresses the named JPEG file, or the standard input if no file is named,
and produces an image file on the standard output.  PBMPLUS (PPM/PGM), BMP,
GIF, Targa, or RLE (Utah Raster Toolkit) output format can be selected.
(RLE is supported only if the URT library is available.)</para>
</refsect1>

<refsect1 id='options'><title>OPTIONS</title>
<para>All switch names may be abbreviated; for example,
<option>-grayscale</option>
may be written
<option>-gray</option>
or
<option>-gr</option>.
Most of the "basic" switches can be abbreviated to as little as one letter.
Upper and lower case are equivalent (thus
<option>-BMP</option>
is the same as
<option>-bmp</option>).
British spellings are also accepted (e.g.,
<option>-greyscale</option>),
though for brevity these are not mentioned below.</para>

<para>The basic switches are:</para>
<variablelist remap='TP'>
  <varlistentry>
  <term><option>-colors</option><replaceable> N</replaceable></term>
  <listitem>
<para>Reduce image to at most N colors.  This reduces the number of colors used in
the output image, so that it can be displayed on a colormapped display or
stored in a colormapped file format.  For example, if you have an 8-bit
display, you'd need to reduce to 256 or fewer colors.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><option>-quantize</option><replaceable> N</replaceable></term>
  <listitem>
<para>Same as
<option>-colors</option>.
<option>-colors</option>
is the recommended name,
<option>-quantize</option>
is provided only for backwards compatibility.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><option>-fast</option></term>
  <listitem>
<para>Select recommended processing options for fast, low quality output.  (The
default options are chosen for highest quality output.)  Currently, this is
equivalent to <option>-dct fast -nosmooth -onepass -dither ordered</option>.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><option>-grayscale</option></term>
  <listitem>
<para>Force gray-scale output even if JPEG file is color.  Useful for viewing on
monochrome displays; also,
<command>djpeg</command>
runs noticeably faster in this mode.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><option>-scale</option><replaceable> M/N</replaceable></term>
  <listitem>
<para>Scale the output image by a factor M/N.  Currently the scale factor must be
1/1, 1/2, 1/4, or 1/8.  Scaling is handy if the image is larger than your
screen; also,
<command>djpeg</command>
runs much faster when scaling down the output.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><option>-bmp</option></term>
  <listitem>
<para>Select BMP output format (Windows flavor).  8-bit colormapped format is
emitted if
<option>-colors</option>
or
<option>-grayscale</option>
is specified, or if the JPEG file is gray-scale; otherwise, 24-bit full-color
format is emitted.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><option>-gif</option></term>
  <listitem>
<para>Select GIF output format.  Since GIF does not support more than 256 colors,
<option>-colors 256</option>
is assumed (unless you specify a smaller number of colors).</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><option>-os2</option></term>
  <listitem>
<para>Select BMP output format (OS/2 1.x flavor).  8-bit colormapped format is
emitted if
<option>-colors</option>
or
<option>-grayscale</option>
is specified, or if the JPEG file is gray-scale; otherwise, 24-bit full-color
format is emitted.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><option>-pnm</option></term>
  <listitem>
<para>Select PBMPLUS (PPM/PGM) output format (this is the default format).
PGM is emitted if the JPEG file is gray-scale or if
<option>-grayscale</option>
is specified; otherwise PPM is emitted.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><option>-rle</option></term>
  <listitem>
<para>Select RLE output format.  (Requires URT library.)</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><option>-targa</option></term>
  <listitem>
<para>Select Targa output format.  Gray-scale format is emitted if the JPEG file is
gray-scale or if
<option>-grayscale</option>
is specified; otherwise, colormapped format is emitted if
<option>-colors</option>
is specified; otherwise, 24-bit full-color format is emitted.</para>
  </listitem>
  </varlistentry>
</variablelist>

<para>Switches for advanced users:</para>
<variablelist remap='TP'>
  <varlistentry>
  <term><option>-dct int</option></term>
  <listitem>
<para>Use integer DCT method (default).</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><option>-dct fast</option></term>
  <listitem>
<para>Use fast integer DCT (less accurate).</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><option>-dct float</option></term>
  <listitem>
<para>Use floating-point DCT method.
The float method is very slightly more accurate than the int method, but is
much slower unless your machine has very fast floating-point hardware.  Also
note that results of the floating-point method may vary slightly across
machines, while the integer methods should give the same results everywhere.
The fast integer method is much less accurate than the other two.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><option>-dither fs</option></term>
  <listitem>
<para>Use Floyd-Steinberg dithering in color quantization.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><option>-dither ordered</option></term>
  <listitem>
<para>Use ordered dithering in color quantization.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><option>-dither none</option></term>
  <listitem>
<para>Do not use dithering in color quantization.
By default, Floyd-Steinberg dithering is applied when quantizing colors; this
is slow but usually produces the best results.  Ordered dither is a compromise
between speed and quality; no dithering is fast but usually looks awful.  Note
that these switches have no effect unless color quantization is being done.
Ordered dither is only available in
<option>-onepass</option>
mode.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><option>-map</option><replaceable> file</replaceable></term>
  <listitem>
<para>Quantize to the colors used in the specified image file.  This is useful for
producing multiple files with identical color maps, or for forcing a
predefined set of colors to be used.  The
<emphasis remap='I'>file</emphasis>
must be a GIF or PPM file. This option overrides
<option>-colors</option>
and
<option>-onepass</option>.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><option>-nosmooth</option></term>
  <listitem>
<para>Use a faster, lower-quality upsampling routine.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><option>-onepass</option></term>
  <listitem>
<para>Use one-pass instead of two-pass color quantization.  The one-pass method is
faster and needs less memory, but it produces a lower-quality image.
<option>-onepass</option>
is ignored unless you also say
<option>-colors</option>
<replaceable>N</replaceable>.
Also, the one-pass method is always used for gray-scale output (the two-pass
method is no improvement then).</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><option>-maxmemory</option><replaceable> N</replaceable></term>
  <listitem>
<para>Set limit for amount of memory to use in processing large images.  Value is
in thousands of bytes, or millions of bytes if "M" is attached to the
number.  For example,
<option>-max 4m</option>
selects 4000000 bytes.  If more space is needed, temporary files will be used.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><option>-outfile</option><replaceable> name</replaceable></term>
  <listitem>
<para>Send output image to the named file, not to standard output.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><option>-verbose</option></term>
  <listitem>
<para>Enable debug printout.  More
<option>-v</option>'s
give more output.  Also, version information is printed at startup.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><option>-debug</option></term>
  <listitem>
<para>Same as
<option>-verbose</option>.</para>
  </listitem>
  </varlistentry>
</variablelist>
</refsect1>

<refsect1 id='examples'><title>EXAMPLES</title>
<para>This example decompresses the JPEG file foo.jpg, quantizes it to
256 colors, and saves the output in 8-bit BMP format in foo.bmp:</para>

<para><userinput>djpeg -colors 256 -bmp</userinput>
<emphasis remap='I'>foo.jpg</emphasis>
<emphasis remap='B'>&gt;</emphasis>
<emphasis remap='I'>foo.bmp</emphasis></para>
</refsect1>

<refsect1 id='hints'><title>HINTS</title>
<para>To get a quick preview of an image, use the
<option>-grayscale</option>
and/or
<option>-scale</option>
switches.
<option>-grayscale -scale 1/8</option>
is the fastest case.</para>

<para>Several options are available that trade off image quality to gain speed.
<option>-fast</option>
turns on the recommended settings.</para>

<para><option>-dct fast</option>
and/or
<option>-nosmooth</option>
gain speed at a small sacrifice in quality.
When producing a color-quantized image,
<option>-onepass -dither ordered</option>
is fast but much lower quality than the default behavior.
<option>-dither none</option>
may give acceptable results in two-pass mode, but is seldom tolerable in
one-pass mode.</para>

<para>If you are fortunate enough to have very fast floating point hardware,
<option>-dct float</option> may be even faster than <option>-dct fast</option>.  But on most
machines <option>-dct float</option> is slower than <option>-dct int</option>; in this case it is
not worth using, because its theoretical accuracy advantage is too small to be
significant in practice.</para>
</refsect1>

<refsect1 id='environment'><title>ENVIRONMENT</title>
<variablelist remap='TP'>
  <varlistentry>
  <term><emphasis remap='B'>JPEGMEM</emphasis></term>
  <listitem>
<para>If this environment variable is set, its value is the default memory limit.
The value is specified as described for the
<option>-maxmemory</option>
switch.
<emphasis remap='B'>JPEGMEM</emphasis>
overrides the default value specified when the program was compiled, and
itself is overridden by an explicit
<option>-maxmemory</option>.</para>
  </listitem>
  </varlistentry>
</variablelist>
</refsect1>

<refsect1 id='see_also'><title>SEE ALSO</title>
<para><citerefentry><refentrytitle>cjpeg</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>jpegtran</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>rdjpgcom</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>wrjpgcom</refentrytitle><manvolnum>1</manvolnum></citerefentry>
<!-- .br -->
<citerefentry><refentrytitle>ppm</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
<citerefentry><refentrytitle>pgm</refentrytitle><manvolnum>5</manvolnum></citerefentry>
<!-- .br -->
Wallace, Gregory K.  "The JPEG Still Picture Compression Standard",
Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44.</para>
</refsect1>

<refsect1 id='author'><title>AUTHOR</title>
<para>Independent JPEG Group</para>
</refsect1>

<refsect1 id='bugs'><title>BUGS</title>
<para>Arithmetic coding is not supported for legal reasons.</para>

<para>To avoid the Unisys LZW patent,
<command>djpeg</command>
produces uncompressed GIF files.  These are larger than they should be, but
are readable by standard GIF decoders.</para>

<para>Still not as fast as we'd like.</para>
</refsect1>
</refentry>

