source: trunk/libjpeg/cjpeg.1 @ 426

Last change on this file since 426 was 283, checked in by rbri, 12 years ago

JPEG plugin: libjpeg updated to version 7

File size: 11.5 KB
Line 
1.TH CJPEG 1 "10 June 2009"
2.SH NAME
3cjpeg \- compress an image file to a JPEG file
4.SH SYNOPSIS
5.B cjpeg
6[
7.I options
8]
9[
10.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.
18The currently supported input file formats are: PPM (PBMPLUS color
19format), PGM (PBMPLUS gray-scale format), BMP, Targa, and RLE (Utah Raster
20Toolkit format).  (RLE is supported only if the URT library is available.)
21.SH OPTIONS
22All 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
30.B \-BMP
31is the same as
32.BR \-bmp ).
33British spellings are also accepted (e.g.,
34.BR \-greyscale ),
35though for brevity these are not mentioned below.
36.PP
37The basic switches are:
38.TP
39.BI \-quality " N[,...]"
40Scale quantization tables to adjust image quality.  Quality is 0 (worst) to
41100 (best); default is 75.  (See below for more info.)
42.TP
43.B \-grayscale
44Create monochrome JPEG file from color input.  Be sure to use this switch when
45compressing a grayscale BMP file, because
46.B cjpeg
47isn't bright enough to notice whether a BMP file uses only shades of gray.
48By saying
49.BR \-grayscale ,
50you'll get a smaller JPEG file that takes less time to process.
51.TP
52.B \-optimize
53Perform optimization of entropy encoding parameters.  Without this, default
54encoding parameters are used.
55.B \-optimize
56usually makes the JPEG file a little smaller, but
57.B cjpeg
58runs somewhat slower and needs much more memory.  Image quality and speed of
59decompression are unaffected by
60.BR \-optimize .
61.TP
62.B \-progressive
63Create progressive JPEG file (see below).
64.TP
65.BI \-scale " M/N"
66Scale the output image by a factor M/N.  Currently supported scale factors are
678/N with all N from 1 to 16.
68.TP
69.B \-targa
70Input file is Targa format.  Targa files that contain an "identification"
71field will not be automatically recognized by
72.BR cjpeg ;
73for such files you must specify
74.B \-targa
75to make
76.B cjpeg
77treat the input as Targa format.
78For most Targa files, you won't need this switch.
79.PP
80The
81.B \-quality
82switch lets you trade off compressed file size against quality of the
83reconstructed image: the higher the quality setting, the larger the JPEG file,
84and the closer the output image will be to the original input.  Normally you
85want to use the lowest quality setting (smallest file) that decompresses into
86something visually indistinguishable from the original image.  For this
87purpose the quality setting should be between 50 and 95; the default of 75 is
88often about right.  If you see defects at
89.B \-quality
9075, then go up 5 or 10 counts at a time until you are happy with the output
91image.  (The optimal setting will vary from one image to another.)
92.PP
93.B \-quality
94100 will generate a quantization table of all 1's, minimizing loss in the
95quantization step (but there is still information loss in subsampling, as well
96as roundoff error).  This setting is mainly of interest for experimental
97purposes.  Quality values above about 95 are
98.B not
99recommended for normal use; the compressed file size goes up dramatically for
100hardly any gain in output image quality.
101.PP
102In the other direction, quality values below 50 will produce very small files
103of low image quality.  Settings around 5 to 10 might be useful in preparing an
104index of a large image library, for example.  Try
105.B \-quality
1062 (or so) for some amusing Cubist effects.  (Note: quality
107values below about 25 generate 2-byte quantization tables, which are
108considered optional in the JPEG standard.
109.B cjpeg
110emits a warning message when you give such a quality value, because some
111other JPEG programs may be unable to decode the resulting file.  Use
112.B \-baseline
113if you need to ensure compatibility at low quality values.)
114.PP
115The
116.B \-quality
117option has been extended in IJG version 7 for support of separate quality
118settings for luminance and chrominance (or in general, for every provided
119quantization table slot).  This feature is useful for high-quality
120applications which cannot accept the damage of color data by coarse
121subsampling settings.  You can now easily reduce the color data amount more
122smoothly with finer control without separate subsampling.  The resulting file
123is fully compliant with standard JPEG decoders.
124Note that the
125.B \-quality
126ratings refer to the quantization table slots, and that the last value is
127replicated if there are more q-table slots than parameters.  The default
128q-table slots are 0 for luminance and 1 for chrominance with default tables as
129given in the JPEG standard.  This is compatible with the old behaviour in case
130that only one parameter is given, which is then used for both luminance and
131chrominance (slots 0 and 1).  More or custom quantization tables can be set
132with
133.B \-qtables
134and assigned to components with
135.B \-qslots
136parameter (see the "wizard" switches below).
137.B Caution:
138You must explicitely add
139.BI \-sample " 1x1"
140for efficient separate color
141quality selection, since the default value used by library is 2x2!
142.PP
143The
144.B \-progressive
145switch creates a "progressive JPEG" file.  In this type of JPEG file, the data
146is stored in multiple scans of increasing quality.  If the file is being
147transmitted over a slow communications link, the decoder can use the first
148scan to display a low-quality image very quickly, and can then improve the
149display with each subsequent scan.  The final image is exactly equivalent to a
150standard JPEG file of the same quality setting, and the total file size is
151about the same --- often a little smaller.
152.PP
153Switches for advanced users:
154.TP
155.B \-dct int
156Use integer DCT method (default).
157.TP
158.B \-dct fast
159Use fast integer DCT (less accurate).
160.TP
161.B \-dct float
162Use floating-point DCT method.
163The float method is very slightly more accurate than the int method, but is
164much slower unless your machine has very fast floating-point hardware.  Also
165note that results of the floating-point method may vary slightly across
166machines, while the integer methods should give the same results everywhere.
167The fast integer method is much less accurate than the other two.
168.TP
169.B \-nosmooth
170Don't use high-quality downsampling.
171.TP
172.BI \-restart " N"
173Emit a JPEG restart marker every N MCU rows, or every N MCU blocks if "B" is
174attached to the number.
175.B \-restart 0
176(the default) means no restart markers.
177.TP
178.BI \-smooth " N"
179Smooth the input image to eliminate dithering noise.  N, ranging from 1 to
180100, indicates the strength of smoothing.  0 (the default) means no smoothing.
181.TP
182.BI \-maxmemory " N"
183Set limit for amount of memory to use in processing large images.  Value is
184in thousands of bytes, or millions of bytes if "M" is attached to the
185number.  For example,
186.B \-max 4m
187selects 4000000 bytes.  If more space is needed, temporary files will be used.
188.TP
189.BI \-outfile " name"
190Send output image to the named file, not to standard output.
191.TP
192.B \-verbose
193Enable debug printout.  More
194.BR \-v 's
195give more output.  Also, version information is printed at startup.
196.TP
197.B \-debug
198Same as
199.BR \-verbose .
200.PP
201The
202.B \-restart
203option inserts extra markers that allow a JPEG decoder to resynchronize after
204a transmission error.  Without restart markers, any damage to a compressed
205file will usually ruin the image from the point of the error to the end of the
206image; with restart markers, the damage is usually confined to the portion of
207the image up to the next restart marker.  Of course, the restart markers
208occupy extra space.  We recommend
209.B \-restart 1
210for images that will be transmitted across unreliable networks such as Usenet.
211.PP
212The
213.B \-smooth
214option filters the input to eliminate fine-scale noise.  This is often useful
215when converting dithered images to JPEG: a moderate smoothing factor of 10 to
21650 gets rid of dithering patterns in the input file, resulting in a smaller
217JPEG file and a better-looking image.  Too large a smoothing factor will
218visibly blur the image, however.
219.PP
220Switches for wizards:
221.TP
222.B \-arithmetic
223Use arithmetic coding.
224.B Caution:
225arithmetic coded JPEG is not yet widely implemented, so many decoders will be
226unable to view an arithmetic coded JPEG file at all.
227.TP
228.B \-baseline
229Force baseline-compatible quantization tables to be generated.  This clamps
230quantization values to 8 bits even at low quality settings.  (This switch is
231poorly named, since it does not ensure that the output is actually baseline
232JPEG.  For example, you can use
233.B \-baseline
234and
235.B \-progressive
236together.)
237.TP
238.BI \-qtables " file"
239Use the quantization tables given in the specified text file.
240.TP
241.BI \-qslots " N[,...]"
242Select which quantization table to use for each color component.
243.TP
244.BI \-sample " HxV[,...]"
245Set JPEG sampling factors for each color component.
246.TP
247.BI \-scans " file"
248Use the scan script given in the specified text file.
249.PP
250The "wizard" switches are intended for experimentation with JPEG.  If you
251don't know what you are doing, \fBdon't use them\fR.  These switches are
252documented further in the file wizard.txt.
253.SH EXAMPLES
254.LP
255This example compresses the PPM file foo.ppm with a quality factor of
25660 and saves the output as foo.jpg:
257.IP
258.B cjpeg \-quality
259.I 60 foo.ppm
260.B >
261.I foo.jpg
262.SH HINTS
263Color GIF files are not the ideal input for JPEG; JPEG is really intended for
264compressing full-color (24-bit) images.  In particular, don't try to convert
265cartoons, line drawings, and other images that have only a few distinct
266colors.  GIF works great on these, JPEG does not.  If you want to convert a
267GIF to JPEG, you should experiment with
268.BR cjpeg 's
269.B \-quality
270and
271.B \-smooth
272options to get a satisfactory conversion.
273.B \-smooth 10
274or so is often helpful.
275.PP
276Avoid running an image through a series of JPEG compression/decompression
277cycles.  Image quality loss will accumulate; after ten or so cycles the image
278may be noticeably worse than it was after one cycle.  It's best to use a
279lossless format while manipulating an image, then convert to JPEG format when
280you are ready to file the image away.
281.PP
282The
283.B \-optimize
284option to
285.B cjpeg
286is worth using when you are making a "final" version for posting or archiving.
287It's also a win when you are using low quality settings to make very small
288JPEG files; the percentage improvement is often a lot more than it is on
289larger files.  (At present,
290.B \-optimize
291mode is always selected when generating progressive JPEG files.)
292.SH ENVIRONMENT
293.TP
294.B JPEGMEM
295If this environment variable is set, its value is the default memory limit.
296The value is specified as described for the
297.B \-maxmemory
298switch.
299.B JPEGMEM
300overrides the default value specified when the program was compiled, and
301itself is overridden by an explicit
302.BR \-maxmemory .
303.SH SEE ALSO
304.BR djpeg (1),
305.BR jpegtran (1),
306.BR rdjpgcom (1),
307.BR wrjpgcom (1)
308.br
309.BR ppm (5),
310.BR pgm (5)
311.br
312Wallace, Gregory K.  "The JPEG Still Picture Compression Standard",
313Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44.
314.SH AUTHOR
315Independent JPEG Group
316.SH BUGS
317GIF input files are no longer supported, to avoid the Unisys LZW patent.
318(Conversion of GIF files to JPEG is usually a bad idea anyway.)
319.PP
320Not all variants of BMP and Targa file formats are supported.
321.PP
322The
323.B \-targa
324switch is not a bug, it's a feature.  (It would be a bug if the Targa format
325designers had not been clueless.)
Note: See TracBrowser for help on using the repository browser.