2 |
- |
1 |
.TH CJPEG 1 "20 March 1998"
|
|
|
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 |
.B \-targa
|
|
|
66 |
Input file is Targa format. Targa files that contain an "identification"
|
|
|
67 |
field will not be automatically recognized by
|
|
|
68 |
.BR cjpeg ;
|
|
|
69 |
for such files you must specify
|
|
|
70 |
.B \-targa
|
|
|
71 |
to make
|
|
|
72 |
.B cjpeg
|
|
|
73 |
treat the input as Targa format.
|
|
|
74 |
For most Targa files, you won't need this switch.
|
|
|
75 |
.PP
|
|
|
76 |
The
|
|
|
77 |
.B \-quality
|
|
|
78 |
switch lets you trade off compressed file size against quality of the
|
|
|
79 |
reconstructed image: the higher the quality setting, the larger the JPEG file,
|
|
|
80 |
and the closer the output image will be to the original input. Normally you
|
|
|
81 |
want to use the lowest quality setting (smallest file) that decompresses into
|
|
|
82 |
something visually indistinguishable from the original image. For this
|
|
|
83 |
purpose the quality setting should be between 50 and 95; the default of 75 is
|
|
|
84 |
often about right. If you see defects at
|
|
|
85 |
.B \-quality
|
|
|
86 |
75, then go up 5 or 10 counts at a time until you are happy with the output
|
|
|
87 |
image. (The optimal setting will vary from one image to another.)
|
|
|
88 |
.PP
|
|
|
89 |
.B \-quality
|
|
|
90 |
100 will generate a quantization table of all 1's, minimizing loss in the
|
|
|
91 |
quantization step (but there is still information loss in subsampling, as well
|
|
|
92 |
as roundoff error). This setting is mainly of interest for experimental
|
|
|
93 |
purposes. Quality values above about 95 are
|
|
|
94 |
.B not
|
|
|
95 |
recommended for normal use; the compressed file size goes up dramatically for
|
|
|
96 |
hardly any gain in output image quality.
|
|
|
97 |
.PP
|
|
|
98 |
In the other direction, quality values below 50 will produce very small files
|
|
|
99 |
of low image quality. Settings around 5 to 10 might be useful in preparing an
|
|
|
100 |
index of a large image library, for example. Try
|
|
|
101 |
.B \-quality
|
|
|
102 |
2 (or so) for some amusing Cubist effects. (Note: quality
|
|
|
103 |
values below about 25 generate 2-byte quantization tables, which are
|
|
|
104 |
considered optional in the JPEG standard.
|
|
|
105 |
.B cjpeg
|
|
|
106 |
emits a warning message when you give such a quality value, because some
|
|
|
107 |
other JPEG programs may be unable to decode the resulting file. Use
|
|
|
108 |
.B \-baseline
|
|
|
109 |
if you need to ensure compatibility at low quality values.)
|
|
|
110 |
.PP
|
|
|
111 |
The
|
|
|
112 |
.B \-progressive
|
|
|
113 |
switch creates a "progressive JPEG" file. In this type of JPEG file, the data
|
|
|
114 |
is stored in multiple scans of increasing quality. If the file is being
|
|
|
115 |
transmitted over a slow communications link, the decoder can use the first
|
|
|
116 |
scan to display a low-quality image very quickly, and can then improve the
|
|
|
117 |
display with each subsequent scan. The final image is exactly equivalent to a
|
|
|
118 |
standard JPEG file of the same quality setting, and the total file size is
|
|
|
119 |
about the same --- often a little smaller.
|
|
|
120 |
.B Caution:
|
|
|
121 |
progressive JPEG is not yet widely implemented, so many decoders will be
|
|
|
122 |
unable to view a progressive JPEG file at all.
|
|
|
123 |
.PP
|
|
|
124 |
Switches for advanced users:
|
|
|
125 |
.TP
|
|
|
126 |
.B \-dct int
|
|
|
127 |
Use integer DCT method (default).
|
|
|
128 |
.TP
|
|
|
129 |
.B \-dct fast
|
|
|
130 |
Use fast integer DCT (less accurate).
|
|
|
131 |
.TP
|
|
|
132 |
.B \-dct float
|
|
|
133 |
Use floating-point DCT method.
|
|
|
134 |
The float method is very slightly more accurate than the int method, but is
|
|
|
135 |
much slower unless your machine has very fast floating-point hardware. Also
|
|
|
136 |
note that results of the floating-point method may vary slightly across
|
|
|
137 |
machines, while the integer methods should give the same results everywhere.
|
|
|
138 |
The fast integer method is much less accurate than the other two.
|
|
|
139 |
.TP
|
|
|
140 |
.BI \-restart " N"
|
|
|
141 |
Emit a JPEG restart marker every N MCU rows, or every N MCU blocks if "B" is
|
|
|
142 |
attached to the number.
|
|
|
143 |
.B \-restart 0
|
|
|
144 |
(the default) means no restart markers.
|
|
|
145 |
.TP
|
|
|
146 |
.BI \-smooth " N"
|
|
|
147 |
Smooth the input image to eliminate dithering noise. N, ranging from 1 to
|
|
|
148 |
100, indicates the strength of smoothing. 0 (the default) means no smoothing.
|
|
|
149 |
.TP
|
|
|
150 |
.BI \-maxmemory " N"
|
|
|
151 |
Set limit for amount of memory to use in processing large images. Value is
|
|
|
152 |
in thousands of bytes, or millions of bytes if "M" is attached to the
|
|
|
153 |
number. For example,
|
|
|
154 |
.B \-max 4m
|
|
|
155 |
selects 4000000 bytes. If more space is needed, temporary files will be used.
|
|
|
156 |
.TP
|
|
|
157 |
.BI \-outfile " name"
|
|
|
158 |
Send output image to the named file, not to standard output.
|
|
|
159 |
.TP
|
|
|
160 |
.B \-verbose
|
|
|
161 |
Enable debug printout. More
|
|
|
162 |
.BR \-v 's
|
|
|
163 |
give more output. Also, version information is printed at startup.
|
|
|
164 |
.TP
|
|
|
165 |
.B \-debug
|
|
|
166 |
Same as
|
|
|
167 |
.BR \-verbose .
|
|
|
168 |
.PP
|
|
|
169 |
The
|
|
|
170 |
.B \-restart
|
|
|
171 |
option inserts extra markers that allow a JPEG decoder to resynchronize after
|
|
|
172 |
a transmission error. Without restart markers, any damage to a compressed
|
|
|
173 |
file will usually ruin the image from the point of the error to the end of the
|
|
|
174 |
image; with restart markers, the damage is usually confined to the portion of
|
|
|
175 |
the image up to the next restart marker. Of course, the restart markers
|
|
|
176 |
occupy extra space. We recommend
|
|
|
177 |
.B \-restart 1
|
|
|
178 |
for images that will be transmitted across unreliable networks such as Usenet.
|
|
|
179 |
.PP
|
|
|
180 |
The
|
|
|
181 |
.B \-smooth
|
|
|
182 |
option filters the input to eliminate fine-scale noise. This is often useful
|
|
|
183 |
when converting dithered images to JPEG: a moderate smoothing factor of 10 to
|
|
|
184 |
50 gets rid of dithering patterns in the input file, resulting in a smaller
|
|
|
185 |
JPEG file and a better-looking image. Too large a smoothing factor will
|
|
|
186 |
visibly blur the image, however.
|
|
|
187 |
.PP
|
|
|
188 |
Switches for wizards:
|
|
|
189 |
.TP
|
|
|
190 |
.B \-baseline
|
|
|
191 |
Force baseline-compatible quantization tables to be generated. This clamps
|
|
|
192 |
quantization values to 8 bits even at low quality settings. (This switch is
|
|
|
193 |
poorly named, since it does not ensure that the output is actually baseline
|
|
|
194 |
JPEG. For example, you can use
|
|
|
195 |
.B \-baseline
|
|
|
196 |
and
|
|
|
197 |
.B \-progressive
|
|
|
198 |
together.)
|
|
|
199 |
.TP
|
|
|
200 |
.BI \-qtables " file"
|
|
|
201 |
Use the quantization tables given in the specified text file.
|
|
|
202 |
.TP
|
|
|
203 |
.BI \-qslots " N[,...]"
|
|
|
204 |
Select which quantization table to use for each color component.
|
|
|
205 |
.TP
|
|
|
206 |
.BI \-sample " HxV[,...]"
|
|
|
207 |
Set JPEG sampling factors for each color component.
|
|
|
208 |
.TP
|
|
|
209 |
.BI \-scans " file"
|
|
|
210 |
Use the scan script given in the specified text file.
|
|
|
211 |
.PP
|
|
|
212 |
The "wizard" switches are intended for experimentation with JPEG. If you
|
|
|
213 |
don't know what you are doing, \fBdon't use them\fR. These switches are
|
|
|
214 |
documented further in the file wizard.doc.
|
|
|
215 |
.SH EXAMPLES
|
|
|
216 |
.LP
|
|
|
217 |
This example compresses the PPM file foo.ppm with a quality factor of
|
|
|
218 |
60 and saves the output as foo.jpg:
|
|
|
219 |
.IP
|
|
|
220 |
.B cjpeg \-quality
|
|
|
221 |
.I 60 foo.ppm
|
|
|
222 |
.B >
|
|
|
223 |
.I foo.jpg
|
|
|
224 |
.SH HINTS
|
|
|
225 |
Color GIF files are not the ideal input for JPEG; JPEG is really intended for
|
|
|
226 |
compressing full-color (24-bit) images. In particular, don't try to convert
|
|
|
227 |
cartoons, line drawings, and other images that have only a few distinct
|
|
|
228 |
colors. GIF works great on these, JPEG does not. If you want to convert a
|
|
|
229 |
GIF to JPEG, you should experiment with
|
|
|
230 |
.BR cjpeg 's
|
|
|
231 |
.B \-quality
|
|
|
232 |
and
|
|
|
233 |
.B \-smooth
|
|
|
234 |
options to get a satisfactory conversion.
|
|
|
235 |
.B \-smooth 10
|
|
|
236 |
or so is often helpful.
|
|
|
237 |
.PP
|
|
|
238 |
Avoid running an image through a series of JPEG compression/decompression
|
|
|
239 |
cycles. Image quality loss will accumulate; after ten or so cycles the image
|
|
|
240 |
may be noticeably worse than it was after one cycle. It's best to use a
|
|
|
241 |
lossless format while manipulating an image, then convert to JPEG format when
|
|
|
242 |
you are ready to file the image away.
|
|
|
243 |
.PP
|
|
|
244 |
The
|
|
|
245 |
.B \-optimize
|
|
|
246 |
option to
|
|
|
247 |
.B cjpeg
|
|
|
248 |
is worth using when you are making a "final" version for posting or archiving.
|
|
|
249 |
It's also a win when you are using low quality settings to make very small
|
|
|
250 |
JPEG files; the percentage improvement is often a lot more than it is on
|
|
|
251 |
larger files. (At present,
|
|
|
252 |
.B \-optimize
|
|
|
253 |
mode is always selected when generating progressive JPEG files.)
|
|
|
254 |
.SH ENVIRONMENT
|
|
|
255 |
.TP
|
|
|
256 |
.B JPEGMEM
|
|
|
257 |
If this environment variable is set, its value is the default memory limit.
|
|
|
258 |
The value is specified as described for the
|
|
|
259 |
.B \-maxmemory
|
|
|
260 |
switch.
|
|
|
261 |
.B JPEGMEM
|
|
|
262 |
overrides the default value specified when the program was compiled, and
|
|
|
263 |
itself is overridden by an explicit
|
|
|
264 |
.BR \-maxmemory .
|
|
|
265 |
.SH SEE ALSO
|
|
|
266 |
.BR djpeg (1),
|
|
|
267 |
.BR jpegtran (1),
|
|
|
268 |
.BR rdjpgcom (1),
|
|
|
269 |
.BR wrjpgcom (1)
|
|
|
270 |
.br
|
|
|
271 |
.BR ppm (5),
|
|
|
272 |
.BR pgm (5)
|
|
|
273 |
.br
|
|
|
274 |
Wallace, Gregory K. "The JPEG Still Picture Compression Standard",
|
|
|
275 |
Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44.
|
|
|
276 |
.SH AUTHOR
|
|
|
277 |
Independent JPEG Group
|
|
|
278 |
.SH BUGS
|
|
|
279 |
Arithmetic coding is not supported for legal reasons.
|
|
|
280 |
.PP
|
|
|
281 |
GIF input files are no longer supported, to avoid the Unisys LZW patent.
|
|
|
282 |
Use a Unisys-licensed program if you need to read a GIF file. (Conversion
|
|
|
283 |
of GIF files to JPEG is usually a bad idea anyway.)
|
|
|
284 |
.PP
|
|
|
285 |
Not all variants of BMP and Targa file formats are supported.
|
|
|
286 |
.PP
|
|
|
287 |
The
|
|
|
288 |
.B \-targa
|
|
|
289 |
switch is not a bug, it's a feature. (It would be a bug if the Targa format
|
|
|
290 |
designers had not been clueless.)
|
|
|
291 |
.PP
|
|
|
292 |
Still not as fast as we'd like.
|