# man > djpeg(1)

---
type: CommandReference
command: djpeg
mode: man
section: 1
source: man-pages
---

## Quick Reference

- `djpeg -bmp image.jpg > image.bmp` — decompress to BMP (8-bit if grayscale or reduced colors, otherwise 24-bit)
- `djpeg -gif image.jpg > image.gif` — decompress to GIF (256 colors assumed unless `-colors` specified)
- `djpeg -pnm image.jpg > image.pgm` — decompress to PGM if grayscale, otherwise PPM
- `djpeg -targa image.jpg > image.tga` — decompress to Targa (colormapped if `-colors`, else 24-bit)
- `djpeg -grayscale -scale 1/4 image.jpg > image.pgm` — force grayscale and scale down
- `djpeg -colors 256 -bmp image.jpg > image.bmp` — quantize to 256 colors, output BMP
- `djpeg -fast -outfile output.jpg input.jpg` — fast decompression using recommended settings
- `djpeg -crop 10x10+100+100 -targa image.jpg > crop.tga` — crop a rectangular region

## Name

djpeg — decompress a JPEG file to an image file

## Synopsis

**djpeg** [ _options_ ] [ _filename_ ]

## Options

All switches may be abbreviated; case-insensitive and British spellings accepted. Basic switches can be abbreviated to as little as one letter.

### Basic switches

- `-colors N` — Reduce image to at most N colors (for colormapped displays or file formats). Also `-quantize`.
- `-quantize N` — Same as `-colors` (backwards compatibility).
- `-fast` — Equivalent to `-dct fast -nosmooth -onepass -dither ordered`. Sacrifices quality for speed.
- `-grayscale` — Force grayscale output even if color JPEG. Faster decompression.
- `-rgb` — (No effect listed; placeholder for RGB output format?)
- `-scale M/N` — Scale output image by factor M/N (M integer 1-16, fraction reduced, e.g. 1/2). Faster when scaling down.
- `-bmp` — Output BMP format. 8-bit colormapped if `-colors` or `-grayscale` or grayscale JPEG; otherwise 24-bit.
- `-gif` — Output GIF format. Default 256 colors unless `-colors` specified; with `-fast` default is 216.
- `-gif0` — Output GIF0 format. Same color behavior as `-gif`.
- `-os2` — Output OS/2 BMP format. Same color behavior as `-bmp`.
- `-pnm` — Output PBMPLUS (PPM/PGM) format. PGM if grayscale or `-grayscale`; otherwise PPM.
- `-targa` — Output Targa format. Grayscale if `-grayscale`; colormapped if `-colors`; otherwise 24-bit.

### Advanced switches

- `-dct int` — Use accurate integer DCT method (default).
- `-dct fast` — Use less accurate integer DCT method. About 5-15% faster on modern CPUs; quality loss noticeable for images compressed above quality 85.
- `-dct float` — Use floating-point DCT method. No more accurate, much slower, machine-dependent.
- `-dither fs` — Floyd-Steinberg dithering (default, slow but best quality).
- `-dither ordered` — Ordered dithering (compromise between speed and quality).
- `-dither none` — No dithering (fast but poor quality). Only effective with color quantization.
- `-icc file` — Extract ICC color profile to the specified file.
- `-map file` — Quantize to colors from the given image file (GIF or PPM). Overrides `-colors` and `-onepass`.
- `-nosmooth` — Faster, lower-quality upsampling.
- `-onepass` — Use one-pass color quantization (faster, less memory, lower quality). Ignored without `-colors N`. Always used for grayscale.
- `-maxmemory N` — Limit memory usage in thousands of bytes (or millions with "M", e.g. `-max 4m`).
- `-maxscans N` — Abort if JPEG contains more than N scans. Guards against denial-of-service attacks via malformed images.
- `-outfile file` — Send output to named file instead of standard output.
- `-memsrc` — Load input file into memory before decompressing (testing feature).
- `-report` — Report decompression progress.
- `-skip Y0-Y1` — Decompress all rows except those between Y0 and Y1 inclusive (relative to scaled dimensions).
- `-crop WxH+X+Y` — Decompress only a rectangular subregion (width, height, start point). Works with PBMPLUS, GIF, Targa formats.
- `-strict` — Treat all warnings as fatal (guard against malformed images).
- `-verbose` / `-debug` — Enable debug output; multiple `-v` increase verbosity.
- `-version` — Print version information and exit.

### Environment

`JPEGMEM` — Default memory limit (same format as `-maxmemory`). Overrides compiled default, overridden by explicit `-maxmemory`.

## Examples

Decompress `foo.jpg`, quantize to 256 colors, save as 8-bit BMP in `foo.bmp`:

shell
djpeg -colors 256 -bmp foo.jpg > foo.bmp
## 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.