blob: 113efd5209bb39bc2bf8671ef7d1b822a0690f3f [file] [log] [blame]
DRCab706232013-01-18 23:42:31 +00001.TH CJPEG 1 "18 January 2013"
Thomas G. Lanebd543f01991-12-13 00:00:00 +00002.SH NAME
3cjpeg \- compress an image file to a JPEG file
4.SH SYNOPSIS
5.B cjpeg
6[
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +00007.I options
Thomas G. Lane4a6b7301992-03-17 00:00:00 +00008]
9[
Thomas G. Lanebd543f01991-12-13 00:00:00 +000010.I filename
11]
12.LP
13.SH DESCRIPTION
14.LP
15.B cjpeg
16compresses the named image file, or the standard input if no file is
17named, and produces a JPEG/JFIF file on the standard output.
Thomas G. Lane88aeed41992-12-10 00:00:00 +000018The currently supported input file formats are: PPM (PBMPLUS color
Thomas G. Lane5ead57a1998-03-27 00:00:00 +000019format), PGM (PBMPLUS gray-scale format), BMP, Targa, and RLE (Utah Raster
Thomas G. Lanebd543f01991-12-13 00:00:00 +000020Toolkit format). (RLE is supported only if the URT library is available.)
21.SH OPTIONS
Thomas G. Lane88aeed41992-12-10 00:00:00 +000022All switch names may be abbreviated; for example,
23.B \-grayscale
24may be written
25.B \-gray
26or
27.BR \-gr .
28Most of the "basic" switches can be abbreviated to as little as one letter.
29Upper and lower case are equivalent (thus
Thomas G. Lane5ead57a1998-03-27 00:00:00 +000030.B \-BMP
Thomas G. Lane88aeed41992-12-10 00:00:00 +000031is the same as
Thomas G. Lane5ead57a1998-03-27 00:00:00 +000032.BR \-bmp ).
Thomas G. Lane88aeed41992-12-10 00:00:00 +000033British spellings are also accepted (e.g.,
34.BR \-greyscale ),
35though for brevity these are not mentioned below.
36.PP
37The basic switches are:
Thomas G. Lanebd543f01991-12-13 00:00:00 +000038.TP
Guido Vollbeding5996a252009-06-27 00:00:00 +000039.BI \-quality " N[,...]"
Thomas G. Lanebd543f01991-12-13 00:00:00 +000040Scale quantization tables to adjust image quality. Quality is 0 (worst) to
41100 (best); default is 75. (See below for more info.)
42.TP
Thomas G. Lane88aeed41992-12-10 00:00:00 +000043.B \-grayscale
44Create monochrome JPEG file from color input. Be sure to use this switch when
Thomas G. Lane5ead57a1998-03-27 00:00:00 +000045compressing a grayscale BMP file, because
Thomas G. Lane88aeed41992-12-10 00:00:00 +000046.B cjpeg
Thomas G. Lane5ead57a1998-03-27 00:00:00 +000047isn't bright enough to notice whether a BMP file uses only shades of gray.
Thomas G. Lane88aeed41992-12-10 00:00:00 +000048By saying
49.BR \-grayscale ,
50you'll get a smaller JPEG file that takes less time to process.
51.TP
Guido Vollbeding5829cb22012-01-15 00:00:00 +000052.B \-rgb
53Create RGB JPEG file.
54Using this switch suppresses the conversion from RGB
55colorspace input to the default YCbCr JPEG colorspace.
Guido Vollbeding5829cb22012-01-15 00:00:00 +000056.TP
Thomas G. Lane88aeed41992-12-10 00:00:00 +000057.B \-optimize
Thomas G. Lanebd543f01991-12-13 00:00:00 +000058Perform optimization of entropy encoding parameters. Without this, default
59encoding parameters are used.
Thomas G. Lane88aeed41992-12-10 00:00:00 +000060.B \-optimize
Thomas G. Lanebd543f01991-12-13 00:00:00 +000061usually makes the JPEG file a little smaller, but
62.B cjpeg
Thomas G. Lane4a6b7301992-03-17 00:00:00 +000063runs somewhat slower and needs much more memory. Image quality and speed of
64decompression are unaffected by
Thomas G. Lane88aeed41992-12-10 00:00:00 +000065.BR \-optimize .
Thomas G. Lanebd543f01991-12-13 00:00:00 +000066.TP
Thomas G. Lanebc79e061995-08-02 00:00:00 +000067.B \-progressive
68Create progressive JPEG file (see below).
69.TP
Thomas G. Lane88aeed41992-12-10 00:00:00 +000070.B \-targa
Thomas G. Lanebd543f01991-12-13 00:00:00 +000071Input file is Targa format. Targa files that contain an "identification"
72field will not be automatically recognized by
73.BR cjpeg ;
74for such files you must specify
Thomas G. Lane88aeed41992-12-10 00:00:00 +000075.B \-targa
76to make
Thomas G. Lanebd543f01991-12-13 00:00:00 +000077.B cjpeg
Thomas G. Lane88aeed41992-12-10 00:00:00 +000078treat the input as Targa format.
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +000079For most Targa files, you won't need this switch.
Thomas G. Lanebd543f01991-12-13 00:00:00 +000080.PP
81The
Thomas G. Lane88aeed41992-12-10 00:00:00 +000082.B \-quality
Thomas G. Lanebd543f01991-12-13 00:00:00 +000083switch lets you trade off compressed file size against quality of the
Thomas G. Lane88aeed41992-12-10 00:00:00 +000084reconstructed image: the higher the quality setting, the larger the JPEG file,
85and the closer the output image will be to the original input. Normally you
86want to use the lowest quality setting (smallest file) that decompresses into
87something visually indistinguishable from the original image. For this
88purpose the quality setting should be between 50 and 95; the default of 75 is
89often about right. If you see defects at
90.B \-quality
Thomas G. Lanebd543f01991-12-13 00:00:00 +00009175, then go up 5 or 10 counts at a time until you are happy with the output
92image. (The optimal setting will vary from one image to another.)
93.PP
Thomas G. Lane88aeed41992-12-10 00:00:00 +000094.B \-quality
Thomas G. Lanebc79e061995-08-02 00:00:00 +000095100 will generate a quantization table of all 1's, minimizing loss in the
Thomas G. Lanebd543f01991-12-13 00:00:00 +000096quantization step (but there is still information loss in subsampling, as well
97as roundoff error). This setting is mainly of interest for experimental
Thomas G. Lane88aeed41992-12-10 00:00:00 +000098purposes. Quality values above about 95 are
Thomas G. Lanebd543f01991-12-13 00:00:00 +000099.B not
100recommended for normal use; the compressed file size goes up dramatically for
101hardly any gain in output image quality.
102.PP
Thomas G. Lane88aeed41992-12-10 00:00:00 +0000103In the other direction, quality values below 50 will produce very small files
104of low image quality. Settings around 5 to 10 might be useful in preparing an
105index of a large image library, for example. Try
106.B \-quality
1072 (or so) for some amusing Cubist effects. (Note: quality
Thomas G. Lanebd543f01991-12-13 00:00:00 +0000108values below about 25 generate 2-byte quantization tables, which are
Thomas G. Lane88aeed41992-12-10 00:00:00 +0000109considered optional in the JPEG standard.
Thomas G. Lanebd543f01991-12-13 00:00:00 +0000110.B cjpeg
Thomas G. Lane88aeed41992-12-10 00:00:00 +0000111emits a warning message when you give such a quality value, because some
Thomas G. Lanebc79e061995-08-02 00:00:00 +0000112other JPEG programs may be unable to decode the resulting file. Use
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000113.B \-baseline
114if you need to ensure compatibility at low quality values.)
Thomas G. Lane88aeed41992-12-10 00:00:00 +0000115.PP
DRC39ea5622010-10-12 01:55:31 +0000116The \fB-quality\fR option has been extended in this version of \fBcjpeg\fR to
117support separate quality settings for luminance and chrominance (or, in
118general, separate settings for every quantization table slot.) The principle
119is the same as chrominance subsampling: since the human eye is more sensitive
120to spatial changes in brightness than spatial changes in color, the chrominance
121components can be quantized more than the luminance components without
122incurring any visible image quality loss. However, unlike subsampling, this
123feature reduces data in the frequency domain instead of the spatial domain,
124which allows for more fine-grained control. This option is useful in
125quality-sensitive applications, for which the artifacts generated by
126subsampling may be unacceptable.
127.PP
128The \fB-quality\fR option accepts a comma-separated list of parameters, which
DRCccd1bfd2012-01-31 09:53:46 +0000129respectively refer to the quality levels that should be assigned to the
DRC39ea5622010-10-12 01:55:31 +0000130quantization table slots. If there are more q-table slots than parameters,
131then the last parameter is replicated. Thus, if only one quality parameter is
132given, this is used for both luminance and chrominance (slots 0 and 1,
133respectively), preserving the legacy behavior of cjpeg v6b and prior.
134More (or customized) quantization tables can be set with the \fB-qtables\fR
135option and assigned to components with the \fB-qslots\fR option (see the
136"wizard" switches below.)
137.PP
138JPEG files generated with separate luminance and chrominance quality are fully
139compliant with standard JPEG decoders.
140.PP
141.BR CAUTION:
142For this setting to be useful, be sure to pass an argument of \fB-sample 1x1\fR
143to \fBcjpeg\fR to disable chrominance subsampling. Otherwise, the default
144subsampling level (2x2, AKA "4:2:0") will be used.
Guido Vollbeding5996a252009-06-27 00:00:00 +0000145.PP
146The
Thomas G. Lanebc79e061995-08-02 00:00:00 +0000147.B \-progressive
148switch creates a "progressive JPEG" file. In this type of JPEG file, the data
149is stored in multiple scans of increasing quality. If the file is being
150transmitted over a slow communications link, the decoder can use the first
151scan to display a low-quality image very quickly, and can then improve the
152display with each subsequent scan. The final image is exactly equivalent to a
153standard JPEG file of the same quality setting, and the total file size is
154about the same --- often a little smaller.
Thomas G. Lanebc79e061995-08-02 00:00:00 +0000155.PP
Thomas G. Lane88aeed41992-12-10 00:00:00 +0000156Switches for advanced users:
157.TP
DRCd657ba62012-01-27 09:41:20 +0000158.B \-arithmetic
159Use arithmetic coding.
160.B Caution:
161arithmetic coded JPEG is not yet widely implemented, so many decoders will be
162unable to view an arithmetic coded JPEG file at all.
163.TP
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000164.B \-dct int
165Use integer DCT method (default).
166.TP
167.B \-dct fast
168Use fast integer DCT (less accurate).
169.TP
170.B \-dct float
171Use floating-point DCT method.
Thomas G. Lanea8b67c41995-03-15 00:00:00 +0000172The float method is very slightly more accurate than the int method, but is
173much slower unless your machine has very fast floating-point hardware. Also
174note that results of the floating-point method may vary slightly across
175machines, while the integer methods should give the same results everywhere.
176The fast integer method is much less accurate than the other two.
Thomas G. Lane88aeed41992-12-10 00:00:00 +0000177.TP
178.BI \-restart " N"
179Emit a JPEG restart marker every N MCU rows, or every N MCU blocks if "B" is
180attached to the number.
181.B \-restart 0
182(the default) means no restart markers.
183.TP
184.BI \-smooth " N"
185Smooth the input image to eliminate dithering noise. N, ranging from 1 to
186100, indicates the strength of smoothing. 0 (the default) means no smoothing.
187.TP
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000188.BI \-maxmemory " N"
189Set limit for amount of memory to use in processing large images. Value is
190in thousands of bytes, or millions of bytes if "M" is attached to the
191number. For example,
192.B \-max 4m
193selects 4000000 bytes. If more space is needed, temporary files will be used.
194.TP
195.BI \-outfile " name"
196Send output image to the named file, not to standard output.
197.TP
DRCab706232013-01-18 23:42:31 +0000198.BI \-memdst
199Compress to memory instead of a file. This feature was implemented mainly as a
200way of testing the in-memory destination manager (jpeg_mem_dest()), but it is
201also useful for benchmarking, since it reduces the I/O overhead.
202.TP
Thomas G. Lane88aeed41992-12-10 00:00:00 +0000203.B \-verbose
204Enable debug printout. More
205.BR \-v 's
206give more output. Also, version information is printed at startup.
207.TP
208.B \-debug
209Same as
210.BR \-verbose .
211.PP
212The
213.B \-restart
214option inserts extra markers that allow a JPEG decoder to resynchronize after
215a transmission error. Without restart markers, any damage to a compressed
216file will usually ruin the image from the point of the error to the end of the
217image; with restart markers, the damage is usually confined to the portion of
218the image up to the next restart marker. Of course, the restart markers
219occupy extra space. We recommend
220.B \-restart 1
221for images that will be transmitted across unreliable networks such as Usenet.
222.PP
223The
224.B \-smooth
225option filters the input to eliminate fine-scale noise. This is often useful
Thomas G. Lane5ead57a1998-03-27 00:00:00 +0000226when converting dithered images to JPEG: a moderate smoothing factor of 10 to
22750 gets rid of dithering patterns in the input file, resulting in a smaller
228JPEG file and a better-looking image. Too large a smoothing factor will
229visibly blur the image, however.
Thomas G. Lane88aeed41992-12-10 00:00:00 +0000230.PP
231Switches for wizards:
232.TP
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000233.B \-baseline
Thomas G. Lane5ead57a1998-03-27 00:00:00 +0000234Force baseline-compatible quantization tables to be generated. This clamps
235quantization values to 8 bits even at low quality settings. (This switch is
236poorly named, since it does not ensure that the output is actually baseline
237JPEG. For example, you can use
238.B \-baseline
239and
240.B \-progressive
241together.)
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000242.TP
Thomas G. Lane88aeed41992-12-10 00:00:00 +0000243.BI \-qtables " file"
Thomas G. Lanebc79e061995-08-02 00:00:00 +0000244Use the quantization tables given in the specified text file.
Thomas G. Lane88aeed41992-12-10 00:00:00 +0000245.TP
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000246.BI \-qslots " N[,...]"
Thomas G. Lanebc79e061995-08-02 00:00:00 +0000247Select which quantization table to use for each color component.
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000248.TP
Thomas G. Lane88aeed41992-12-10 00:00:00 +0000249.BI \-sample " HxV[,...]"
Thomas G. Lanebc79e061995-08-02 00:00:00 +0000250Set JPEG sampling factors for each color component.
251.TP
252.BI \-scans " file"
253Use the scan script given in the specified text file.
Thomas G. Lane88aeed41992-12-10 00:00:00 +0000254.PP
255The "wizard" switches are intended for experimentation with JPEG. If you
Thomas G. Lanebc79e061995-08-02 00:00:00 +0000256don't know what you are doing, \fBdon't use them\fR. These switches are
Guido Vollbeding5996a252009-06-27 00:00:00 +0000257documented further in the file wizard.txt.
Thomas G. Lanebd543f01991-12-13 00:00:00 +0000258.SH EXAMPLES
259.LP
260This example compresses the PPM file foo.ppm with a quality factor of
26160 and saves the output as foo.jpg:
262.IP
Thomas G. Lane88aeed41992-12-10 00:00:00 +0000263.B cjpeg \-quality
Thomas G. Lanebd543f01991-12-13 00:00:00 +0000264.I 60 foo.ppm
265.B >
266.I foo.jpg
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000267.SH HINTS
268Color GIF files are not the ideal input for JPEG; JPEG is really intended for
269compressing full-color (24-bit) images. In particular, don't try to convert
270cartoons, line drawings, and other images that have only a few distinct
271colors. GIF works great on these, JPEG does not. If you want to convert a
272GIF to JPEG, you should experiment with
273.BR cjpeg 's
274.B \-quality
275and
276.B \-smooth
277options to get a satisfactory conversion.
278.B \-smooth 10
279or so is often helpful.
280.PP
281Avoid running an image through a series of JPEG compression/decompression
282cycles. Image quality loss will accumulate; after ten or so cycles the image
283may be noticeably worse than it was after one cycle. It's best to use a
284lossless format while manipulating an image, then convert to JPEG format when
285you are ready to file the image away.
286.PP
287The
288.B \-optimize
289option to
290.B cjpeg
291is worth using when you are making a "final" version for posting or archiving.
292It's also a win when you are using low quality settings to make very small
293JPEG files; the percentage improvement is often a lot more than it is on
Thomas G. Lanebc79e061995-08-02 00:00:00 +0000294larger files. (At present,
295.B \-optimize
296mode is always selected when generating progressive JPEG files.)
Thomas G. Lane88aeed41992-12-10 00:00:00 +0000297.SH ENVIRONMENT
298.TP
299.B JPEGMEM
300If this environment variable is set, its value is the default memory limit.
301The value is specified as described for the
302.B \-maxmemory
303switch.
304.B JPEGMEM
305overrides the default value specified when the program was compiled, and
306itself is overridden by an explicit
307.BR \-maxmemory .
Thomas G. Lanebd543f01991-12-13 00:00:00 +0000308.SH SEE ALSO
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000309.BR djpeg (1),
Thomas G. Lanebc79e061995-08-02 00:00:00 +0000310.BR jpegtran (1),
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000311.BR rdjpgcom (1),
312.BR wrjpgcom (1)
Thomas G. Lanebd543f01991-12-13 00:00:00 +0000313.br
Thomas G. Lane4a6b7301992-03-17 00:00:00 +0000314.BR ppm (5),
315.BR pgm (5)
316.br
Thomas G. Lanebd543f01991-12-13 00:00:00 +0000317Wallace, Gregory K. "The JPEG Still Picture Compression Standard",
318Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44.
319.SH AUTHOR
320Independent JPEG Group
DRCcf763c02013-01-01 09:51:37 +0000321.PP
322This file was modified by The libjpeg-turbo Project to include only information
DRCab706232013-01-18 23:42:31 +0000323relevant to libjpeg-turbo, to wordsmith certain sections, and to describe
324features not present in libjpeg.
Thomas G. Lanebd543f01991-12-13 00:00:00 +0000325.SH BUGS
DRC39ea5622010-10-12 01:55:31 +0000326Support for GIF input files was removed in cjpeg v6b due to concerns over
327the Unisys LZW patent. Although this patent expired in 2006, cjpeg still
328lacks GIF support, for these historical reasons. (Conversion of GIF files to
329JPEG is usually a bad idea anyway.)
Thomas G. Lane5ead57a1998-03-27 00:00:00 +0000330.PP
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000331Not all variants of BMP and Targa file formats are supported.
Thomas G. Lanebd543f01991-12-13 00:00:00 +0000332.PP
333The
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000334.B \-targa
Thomas G. Lanebd543f01991-12-13 00:00:00 +0000335switch is not a bug, it's a feature. (It would be a bug if the Targa format
336designers had not been clueless.)