djpeg
Decompress JPEG images to other formats
SYNOPSIS
djpeg [-options] [inputfile]
PARAMETERS
-pbm
Output PBM (portable bit map) format, monochrome only
-pgm
Output PGM (portable graymap) format, grayscale
-ppm
Output PPM (portable pixmap) format (default)
-rgb
Output raw RGB format
-bmp
Output BMP format (Windows bitmap)
-targa
Output Targa format
-rle
Output RLE format (Utah format)
-dct method
Select IDCT method: intact, fast, or float
-fast
Use fast, low-quality DCT (less accurate)
-optimize
Optimize Huffman table (slower)
-outfile name
Write output to specified file
-scale M/N
Scale output by factor M/N (e.g., 1/2, 1/4, 1/8)
-grayscale
Force grayscale output
-colors N
Quantize to N colors (1=gray, 3=color)
-arithmetic
Decode arithmetic-coded JPEG (default: Huffman)
-nosmooth
Disable fancy upsampling
-maxmemory N
Max memory in kB (default: 4MB)
-crop WxH+x+y
Crop to specified widthxheight+xoffset+yoffset
DESCRIPTION
djpeg is a command-line utility from the Independent JPEG Group's (IJG) libjpeg software package. It decompresses JPEG-compressed images, converting them into a variety of uncompressed formats suitable for further processing or viewing. By default, it outputs in PPM (Portable Pixmap) format, but supports numerous alternatives including PBM (monochrome), PGM (grayscale), RGB, BMP, Targa, and others.
Key features include selectable DCT (Discrete Cosine Transform) methods for balancing speed and quality, image scaling (e.g., 1/2, 1/4, 1/8 size), grayscale conversion, color reduction, and smoothing filters to reduce artifacts. It handles both Huffman and arithmetic-coded JPEGs, supports crop operations, and allows memory limits for large images. djpeg is ideal for batch processing, scripting, or piping into tools like ImageMagick or Netpbm utilities.
Performance options like -fast enable quicker but less accurate decoding, while -dct float prioritizes precision. It's widely used in Linux environments for JPEG handling due to its efficiency and standards compliance (JPEG/JFIF). Output quality matches the input compression level, preserving details where possible.
CAVEATS
Does not support progressive or lossless JPEG variants fully; GIF output disabled by default due to patents (historical). Large images may require more memory.
INPUT/OUTPUT
Reads from stdin if no inputfile; writes to stdout unless -outfile specified. Supports piped usage, e.g., djpeg -ppm image.jpg | pnmtopng > out.png
QUALITY TRADE-OFFS
-fast speeds up by ~3x but introduces minor artifacts; use -dct float for highest fidelity on supported platforms.
HISTORY
Developed by the Independent JPEG Group (IJG); first released in 1991 as part of libjpeg v5. Evolved through versions up to libjpeg-turbo (modern fork with SIMD optimizations). Remains a standard for JPEG decoding on Unix-like systems.


