LinuxCommandLibrary

cjpeg

Convert image files to JPEG format

SYNOPSIS

cjpeg [options] [filename]

PARAMETERS

-quality {integer}
    Sets the JPEG quality level (0-100, default is 75). Higher values result in better image quality but larger file sizes.

-grayscale
    Forces the output to be grayscale.

-rgb
    Forces the input to be interpreted as RGB.

-optimize
    Optimize Huffman table (smaller file, but slower compression).

-progressive
    Creates a progressive JPEG file. This allows the image to appear gradually as it is downloaded.

-dct {int, fast, float}
    Specifies the DCT algorithm to use (default is 'int'). 'int' is integer-based, 'fast' is a faster, less accurate integer-based DCT, and 'float' is floating-point.

-restart {integer}
    Emit a JPEG restart marker every N rows (default is 0, no restart markers).

-targa
    Specifies that the input file is a Targa format image.

-outfile {filename}
    Specifies the name of the output JPEG file. If not specified, the output is written to standard output.

-memdst
    Use in-memory destination buffer, useful for piping.

-verbose
    Enable verbose mode.

-debug
    Enable debug mode.

-version
    Display version information and exit.

-help
    Display a help message and exit.

[filename]
    The input image file. If not specified, the input is read from standard input.

DESCRIPTION

cjpeg is a command-line tool for converting image files to JPEG format. It is part of the Independent JPEG Group's (IJG) JPEG software. cjpeg reads an image file in one of several supported formats (such as PPM, PGM, BMP, or Targa) and writes it as a JPEG file.
It allows you to control the quality and compression level of the resulting JPEG image, enabling you to balance file size and image quality. It is commonly used for reducing the storage space required for images and for preparing images for web use. cjpeg offers various options to fine-tune the JPEG compression process, including setting the quality, specifying the color space, and optimizing the encoding for progressive display.
It is important to note that the quality factor settings depend heavily on the image. Different images might have different levels of loss from a given quality value.

CAVEATS

The specific image formats supported by cjpeg may vary depending on the version of the IJG JPEG software installed. Using very low quality values can result in significant image degradation. Older systems might not fully support progressive JPEGs.

INPUT FORMATS

cjpeg can read several image formats, including PPM (Portable Pixmap), PGM (Portable Graymap), BMP (Windows Bitmap), and Targa. The specific formats supported may depend on compile-time options.

OUTPUT FILE HANDLING

If the output file name is not specified using the -outfile option, cjpeg writes the JPEG image to standard output. This allows you to pipe the output to other commands or redirect it to a file using shell redirection.

HISTORY

cjpeg is part of the Independent JPEG Group's (IJG) JPEG software, which was initially developed in the early 1990s. It has been a widely used tool for JPEG compression due to its open-source nature and reliable performance. The IJG software has gone through various updates and improvements over the years, but the core functionality of cjpeg has remained consistent.

SEE ALSO

djpeg(1), jpegtran(1)

Copied to clipboard