CJPEGB

Name

cjpegb -- compresses a grayscale or color (RGB) image using lossy Baseline JPEG (JPEGB).

Synopsis

cjpegb <q=20=95><outext><imagefile>
[ -raw_in w,h,d, [ppi] [-nonintrlv ]] [commentfile]

DESCRIPTION

Cjpegb takes as input a file containing an uncompressed grayscale or color (RGB) image. Two possible input file formats are accepted, NIST IHead files and raw pixmap files. If a raw pixmap file is to be compressed, then its image attributes must be provided on the command line as well. Once read into memory, the grayscale or color pixmap is then lossy compressed to a specified level of reconstruction quality using the Independent JPEG Group's (IJG) library for Baseline JPEG (JPEGB). The JPEGB results are then written to an output file.

Note that cjpegb calls the IJG library in a default color mode where one of the compression steps includes a colorspace conversion from RGB to YCbCr, and then the Cb & Cr component planes are downsampled by a factor of 2 in both dimensions. Due to this colorspace conversion, cjpegb should only be used to compress RGB color images.

The color components of RGB pixels in a raw pixmap file may be interleaved or non-interleaved. By default, cjpegb assumes interleaved color pixels. (See INTERLEAVE OPTIONS below.) Regarding color pixmaps, the NIST IHead file format only supports interleaved RGB images.

OPTIONS

All switch names may be abbreviated; for example, -raw_in may be written -r.

<q=20-95>

specifies the level of quality in the reconstructed image as a result of lossy compression. The integer quality value may range between 20 and 95. The lower the quality value, the more drastic the compression.

<outext>

the extension of the compressed output file. To construct the output filename, cjpegb takes the input filename and replaces its extension with the one specified here.

<image file>

the input file, either an IHead file or raw pixmap file, containing the grayscale or color (RGB) image to be compressed.

-raw_in w,h,d,[ppi]

the attributes of the input image. This option must be included on the command line if the input is a raw pixmap file.

w

the pixel width of the pixmap

h

the pixel height of the pixmap

d

the pixel depth of the pixmap

ppi

the optional scan resolution of the image in integer units of pixels per inch.

-nonintrlv

specifies that the color components in an input raw pixmap file image are non-interleaved and stored in separate component planes. (See INTERLEAVE OPTIONS below).

comment file

an optional user-supplied ASCII comment file. (See COMMENT OPTIONS below.)

INTERLEAVE OPTIONS

The color components of RGB pixels in a raw pixmap file may be interleaved or non-interleaved. Color components are interleaved when a pixel's (R)ed, (G)reen, and (B)lue components are sequentially adjacent in the image byte stream, ie. RGBRGBRGB... . If the color components are non-interleaved, then all (R)ed components in the image are sequentially adjacent in the image byte stream, followed by all (G)reen components, and then lastly followed by all (B)lue components. Each complete sequence of color components is called a plane. The utilities intr2not and not2intr convert between interleaved and non-interleaved color components. By default, cjpegb assumes interleaved color components, and note that all color IHead images must be interleaved.

COMMENT OPTIONS

Upon successful compression, this utility generates and inserts in the compressed output file a specially formatted comment block, called a NISTCOM. A NISTCOM is a text-based attribute list comprised of (name, value) pairs, one pair per text line. The first line of a NISTCOM always has name = "NIST_COM" and its value is always the total number of attributes included in the list. The utility rdjpgcom scans a JPEG compressed file for any and all comment blocks. Once found, the contents of each comment block is printed to standard output. Using this utility, the NISTCOM provides easy access to relevant image attributes. The following is an example NISTCOM generated by cjpegb:

NIST_COM 12 PIX_WIDTH 768 PIX_HEIGHT 1024 PIX_DEPTH 24 PPI -1 LOSSY 1 COLORSPACE YCbCr NUM_COMPONENTS 3 HV_FACTORS 2,2:1,1:1,1 INTERLEAVE 1 COMPRESSION JPEGB JPEGB_QUALITY 50

Cjpegb also accepts an optional comment file on the command line. If provided, the contents of this file are also inserted into the compressed output file. If the comment file is a NISTCOM attribute list, then its contents are merged with the NISTCOM internally generated by cjpegb and a single NISTCOM is written to the compressed output file. Note that cjpegb gives precedence to internally generated attribute values. If the user provides a non-NISTCOM comment file, then the contents of file are stored to a separate comment block in the output file. Using these comment options enables the user to store application-specific information in a JPEG file.

EXAMPLES

From test/imgtools/execs/cjpegb/cjpegb.src:

% cjpegb 50 jpb face08.raw -r 768,1024,8 compresses a grayscale face image in a raw pixmap file.

% cjpegb 50 jpb face24.raw -r 768,1024,24 compresses a color face image in a raw pixmap file.

SEE ALSO

cjpeg(1E), cjpegl(1D), djpegb(1D), dpyimage(1D), intr2not(1D), jpegtran(1E), not2intr(1D), rdjpgcom(1E), wrjpgcom(1E)

AUTHOR

NIST/ITL/DIV894/Image Group