# djpeg(1) - man - phpman

[DJPEG(1)](https://www.chedong.com/phpMan.php/man/DJPEG/1/markdown)                               General Commands Manual                              [DJPEG(1)](https://www.chedong.com/phpMan.php/man/DJPEG/1/markdown)



## NAME
       djpeg - decompress a JPEG file to an image file

## SYNOPSIS
       **djpeg** [ _options_ ] [ _filename_ ]

## DESCRIPTION
       **djpeg**  decompresses  the named JPEG file, or the standard input if no file is named, and pro‐
       duces an image file on the standard output.  PBMPLUS (PPM/PGM), BMP,  GIF,  or  Targa  output
       format can be selected.

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

       The basic switches are:

### -colors
              Reduce image to at most N colors.  This reduces the number of colors used in the  out‐
              put  image,  so  that it can be displayed on a colormapped display or stored in a col‐
              ormapped file format.  For example, if you have an 8-bit display, you'd need to reduce
              to 256 or fewer colors.

### -quantize
              Same  as  **-colors**.   **-colors**  is  the recommended name, **-quantize** is provided only for
              backwards compatibility.

### -fast
              tions  are  chosen for highest quality output.)  Currently, this is equivalent to **-dct**
              **fast** **-nosmooth** **-onepass** **-dither** **ordered**.

### -grayscale
              Force grayscale output even if JPEG file is color.  Useful for viewing  on  monochrome
              displays; also, **djpeg** runs noticeably faster in this mode.

### -rgb

### -scale
              Scale the output image by a factor M/N.  Currently the scale factor must be M/8, where
              M is an integer between 1 and 16 inclusive, or any reduced fraction thereof  (such  as
              1/2, 3/4, etc.)  Scaling is handy if the image is larger than your screen; also, **djpeg**
              runs much faster when scaling down the output.

### -bmp
              **-colors**  or  **-grayscale**  is  specified,  or  if the JPEG file is grayscale; otherwise,
              24-bit full-color format is emitted.

### -gif
              colors,  **-colors**  **256**  is assumed (unless you specify a smaller number of colors).  If
              you specify **-fast,** the default number of colors is 216.

### -gif0
              colors,  **-colors**  **256**  is assumed (unless you specify a smaller number of colors).  If
              you specify **-fast,** the default number of colors is 216.

### -os2
              **-colors**  or  **-grayscale**  is  specified,  or  if the JPEG file is grayscale; otherwise,
              24-bit full-color format is emitted.

### -pnm
              if the JPEG file is grayscale or if **-grayscale** is specified; otherwise PPM is emitted.

### -targa
              or if **-grayscale** is specified; otherwise, colormapped format is emitted if **-colors**  is
              specified; otherwise, 24-bit full-color format is emitted.

       Switches for advanced users:

### -dct int
              Use accurate integer DCT method (default).

### -dct fast
              Use  less  accurate  integer  DCT  method [legacy feature].  When the Independent JPEG
              Group's software was first released in 1991, the decompression time for a  1-megapixel
              JPEG image on a mainstream PC was measured in minutes.  Thus, the **fast** integer DCT al‐
              gorithm provided noticeable performance benefits.  On  modern  CPUs  running  libjpeg-
              turbo,  however,  the  decompression  time for a 1-megapixel JPEG image is measured in
              milliseconds, and thus the performance benefits of the **fast** algorithm  are  much  less
              noticeable.   On  modern  x86/x86-64 CPUs that support AVX2 instructions, the **fast** and
              **int** methods have similar performance.  On other types of CPUs, the **fast** method is gen‐
              erally about 5-15% faster than the **int** method.

              If  the  JPEG  image  was  compressed using a quality level of 85 or below, then there
              should be little or no perceptible quality  difference  between  the  two  algorithms.
              When decompressing images that were compressed using quality levels above 85, however,
              the difference between the **fast** and **int** methods becomes more pronounced.  With  images
              compressed  using  quality=97,  for instance, the **fast** method incurs generally about a
              4-6 dB loss in PSNR relative to the **int** method, but this can be larger  for  some  im‐
              ages.   If you can avoid it, do not use the **fast** method when decompressing images that
              were compressed using quality levels above 97.  The algorithm  often  degenerates  for
              such  images and can actually produce a more lossy output image than if the JPEG image
              had been compressed using lower quality levels.

### -dct float
              Use floating-point DCT method [legacy feature].  The **float**  method  does  not  produce
              significantly  more  accurate results than the **int** method, and it is much slower.  The
              **float** method may also give different results on  different  machines  due  to  varying
              roundoff behavior, whereas the integer methods should give the same results on all ma‐
              chines.

### -dither fs
              Use Floyd-Steinberg dithering in color quantization.

### -dither ordered
              Use ordered dithering in color quantization.

### -dither none
              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 quantiza‐
              tion is being done.  Ordered dither is only available in **-onepass** mode.

### -icc
              Extract ICC color management profile to the specified file.

### -map
              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 _file_ must be a GIF or  PPM  file.  This  option  overrides  **-colors**  and
              **-onepass**.

### -nosmooth
              Use a faster, lower-quality upsampling routine.

### -onepass
              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.  **-onepass** is ignored un‐
              less  you  also say **-colors** _N_.  Also, the one-pass method is always used for grayscale
              output (the two-pass method is no improvement then).

### -maxmemory
              Set limit for amount of memory to use in processing large images.  Value is  in  thou‐
              sands  of  bytes, or millions of bytes if "M" is attached to the number.  For example,
              **-max** **4m** selects 4000000 bytes.  If more space is needed, an error will occur.

### -maxscans
              Abort if the JPEG image contains more than  _N_  scans.   This  feature  demonstrates  a
              method by which applications can guard against denial-of-service attacks instigated by
              specially-crafted malformed JPEG images containing numerous scans with  missing  image
              data or image data consisting only of "EOB runs" (a feature of progressive JPEG images
              that allows potentially hundreds of thousands of adjoining  zero-value  pixels  to  be
              represented using only a few bytes.)  Attempting to decompress such malformed JPEG im‐
              ages can cause excessive CPU activity, since the decompressor must fully process  each
              scan (even if the scan is corrupt) before it can proceed to the next scan.

### -outfile
              Send output image to the named file, not to standard output.

### -memsrc
              Load input file into memory before decompressing.  This feature was implemented mainly
              as a way of testing the in-memory source manager (jpeg_mem_src().)

### -report
              Report decompression progress.

### -skip
              Decompress all rows of the JPEG image except those  between  Y0  and  Y1  (inclusive.)
              Note  that  if decompression scaling is being used, then Y0 and Y1 are relative to the
              scaled image dimensions.

### -crop
              Decompress only a rectangular subregion of the image, starting at point X,Y with width
              W  and  height  H.  If necessary, X will be shifted left to the nearest iMCU boundary,
              and the width will be increased accordingly.  Note that if  decompression  scaling  is
              being  used,  then  X,  Y, W, and H are relative to the scaled image dimensions.  Cur‐
              rently this option only works with the PBMPLUS (PPM/PGM), GIF, and Targa  output  for‐
              mats.

### -strict
              Treat  all warnings as fatal.  This feature also demonstrates a method by which appli‐
              cations can guard against attacks instigated by specially-crafted malformed  JPEG  im‐
              ages.   Enabling  this  option  will cause the decompressor to abort if the JPEG image
              contains incomplete or corrupt image data.

### -verbose
              Enable debug printout.  More **-v**'s give more  output.   Also,  version  information  is
              printed at startup.

### -debug -verbose

### -version
              Print version information and exit.

## EXAMPLES
       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:

              **djpeg** **-colors** **256** **-bmp** _foo.jpg_ **>** _foo.bmp_

## HINTS
       To get a quick preview of an image, use the **-grayscale** and/or  **-scale**  switches.   **-grayscale**
### -scale

       Several options are available that trade off image quality to gain speed.  **-fast** turns on the
       recommended settings.

### -dct -nosmooth
       color-quantized  image,  **-onepass** **-dither** **ordered** is fast but much lower quality than the de‐
       fault behavior.  **-dither** **none** may give acceptable results in two-pass  mode,  but  is  seldom
       tolerable in one-pass mode.

## ENVIRONMENT
       **JPEGMEM**
              If this environment variable is set, its value is the default memory limit.  The value
              is specified as described for the **-maxmemory** switch.  **JPEGMEM**  overrides  the  default
              value specified when the program was compiled, and itself is overridden by an explicit
              **-maxmemory**.

## SEE ALSO
       [**cjpeg**(1)](https://www.chedong.com/phpMan.php/man/cjpeg/1/markdown), [**jpegtran**(1)](https://www.chedong.com/phpMan.php/man/jpegtran/1/markdown), [**rdjpgcom**(1)](https://www.chedong.com/phpMan.php/man/rdjpgcom/1/markdown), [**wrjpgcom**(1)](https://www.chedong.com/phpMan.php/man/wrjpgcom/1/markdown)
       [**ppm**(5)](https://www.chedong.com/phpMan.php/man/ppm/5/markdown), [**pgm**(5)](https://www.chedong.com/phpMan.php/man/pgm/5/markdown)
       Wallace, Gregory K.  "The JPEG Still Picture Compression  Standard",  Communications  of  the
       ACM, April 1991 (vol. 34, no. 4), pp. 30-44.

## AUTHOR
       Independent JPEG Group

       This  file  was modified by The libjpeg-turbo Project to include only information relevant to
       libjpeg-turbo, to wordsmith certain sections, and to describe features not  present  in  lib‐
       jpeg.



                                           4 November 2020                                  [DJPEG(1)](https://www.chedong.com/phpMan.php/man/DJPEG/1/markdown)
