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