1CJPEG(1)                    General Commands Manual                   CJPEG(1)
2
3
4

NAME

6       cjpeg - compress an image file to a JPEG file
7

SYNOPSIS

9       cjpeg [ options ] [ filename ]
10

DESCRIPTION

12       cjpeg compresses the named image file, or the standard input if no file
13       is named, and produces a JPEG/JFIF file on the  standard  output.   The
14       currently supported input file formats are: PPM (PBMPLUS color format),
15       PGM (PBMPLUS gray-scale format), BMP, Targa, and RLE (Utah Raster Tool‐
16       kit format).  (RLE is supported only if the URT library is available.)
17

OPTIONS

19       All  switch  names  may  be abbreviated; for example, -grayscale may be
20       written -gray or -gr.  Most of the "basic" switches can be  abbreviated
21       to  as little as one letter.  Upper and lower case are equivalent (thus
22       -BMP is the same as -bmp).  British spellings are also accepted  (e.g.,
23       -greyscale), though for brevity these are not mentioned below.
24
25       The basic switches are:
26
27       -quality N[,...]
28              Scale quantization tables to adjust image quality.  Quality is 0
29              (worst) to 100 (best); default  is  75.   (See  below  for  more
30              info.)
31
32       -grayscale
33              Create  monochrome  JPEG  file from color input.  Be sure to use
34              this switch when compressing a grayscale BMP file, because cjpeg
35              isn't  bright  enough  to  notice  whether  a BMP file uses only
36              shades of gray.  By saying -grayscale, you'll get a smaller JPEG
37              file that takes less time to process.
38
39       -optimize
40              Perform  optimization  of  entropy encoding parameters.  Without
41              this, default encoding parameters are used.   -optimize  usually
42              makes  the  JPEG  file a little smaller, but cjpeg runs somewhat
43              slower and needs much more memory.  Image quality and  speed  of
44              decompression are unaffected by -optimize.
45
46       -progressive
47              Create progressive JPEG file (see below).
48
49       -targa Input  file is Targa format.  Targa files that contain an "iden‐
50              tification" field will not be automatically recognized by cjpeg;
51              for  such  files you must specify -targa to make cjpeg treat the
52              input as Targa format.  For most Targa  files,  you  won't  need
53              this switch.
54
55       The  -quality  switch  lets  you trade off compressed file size against
56       quality of the reconstructed image: the higher the quality setting, the
57       larger  the  JPEG  file, and the closer the output image will be to the
58       original input.  Normally you want to use the  lowest  quality  setting
59       (smallest  file)  that  decompresses  into something visually indistin‐
60       guishable from the original image.  For this purpose the  quality  set‐
61       ting  should  be  between  50  and 95; the default of 75 is often about
62       right.  If you see defects at -quality 75, then go up 5 or 10 counts at
63       a time until you are happy with the output image.  (The optimal setting
64       will vary from one image to another.)
65
66       -quality 100 will generate a quantization table of all 1's,  minimizing
67       loss  in  the quantization step (but there is still information loss in
68       subsampling, as well as roundoff error).  This  setting  is  mainly  of
69       interest  for experimental purposes.  Quality values above about 95 are
70       not recommended for normal use; the compressed file size goes  up  dra‐
71       matically for hardly any gain in output image quality.
72
73       In the other direction, quality values below 50 will produce very small
74       files of low image quality.  Settings around 5 to 10 might be useful in
75       preparing an index of a large image library, for example.  Try -quality
76       2 (or so) for some amusing Cubist effects.  (Note: quality values below
77       about  25  generate  2-byte  quantization  tables, which are considered
78       optional in the JPEG standard.  cjpeg emits a warning message when  you
79       give  such  a  quality  value,  because some other JPEG programs may be
80       unable to decode the resulting file.  Use  -baseline  if  you  need  to
81       ensure compatibility at low quality values.)
82
83       The  -quality option has been extended in this version of cjpeg to sup‐
84       port separate quality settings for luminance and  chrominance  (or,  in
85       general,  separate  settings  for  every quantization table slot.)  The
86       principle is the same as chrominance subsampling:  since the human  eye
87       is more sensitive to spatial changes in brightness than spatial changes
88       in color, the chrominance components can be  quantized  more  than  the
89       luminance  components without incurring any visible image quality loss.
90       However, unlike subsampling, this feature reduces data in the frequency
91       domain  instead  of  the  spatial  domain,  which allows for more fine-
92       grained control.  This option is useful in  quality-sensitive  applica‐
93       tions,  for  which  the artifacts generated by subsampling may be unac‐
94       ceptable.
95
96       The -quality option accepts a comma-separated list of parameters, which
97       respectively  refer  to  the quality levels which should be assigned to
98       the quantization table slots.  If there are  more  q-table  slots  than
99       parameters,  then  the last parameter is replicated.  Thus, if only one
100       quality parameter is given, this is used for both luminance and chromi‐
101       nance  (slots 0 and 1, respectively), preserving the legacy behavior of
102       cjpeg v6b and prior.  More (or customized) quantization tables  can  be
103       set  with  the  -qtables  option  and  assigned  to components with the
104       -qslots option (see the "wizard" switches below.)
105
106       JPEG files generated with separate luminance  and  chrominance  quality
107       are fully compliant with standard JPEG decoders.
108
109       CAUTION:  For this setting to be useful, be sure to pass an argument of
110       -sample 1x1 to cjpeg to disable  chrominance  subsampling.   Otherwise,
111       the default subsampling level (2x2, AKA "4:2:0") will be used.
112
113       The  -progressive  switch  creates  a "progressive JPEG" file.  In this
114       type of JPEG file, the data is stored in multiple scans  of  increasing
115       quality.   If  the file is being transmitted over a slow communications
116       link, the decoder can use the first scan to display a low-quality image
117       very  quickly,  and  can  then improve the display with each subsequent
118       scan.  The final image is exactly equivalent to a standard JPEG file of
119       the same quality setting, and the total file size is about the same ---
120       often a little smaller.
121
122       Switches for advanced users:
123
124       -dct int
125              Use integer DCT method (default).
126
127       -dct fast
128              Use fast integer DCT (less accurate).
129
130       -dct float
131              Use  floating-point  DCT  method.   The  float  method  is  very
132              slightly  more  accurate than the int method, but is much slower
133              unless your machine has very fast floating-point hardware.  Also
134              note that results of the floating-point method may vary slightly
135              across machines, while the integer methods should give the  same
136              results  everywhere.  The fast integer method is much less accu‐
137              rate than the other two.
138
139       -restart N
140              Emit a JPEG restart marker every N MCU  rows,  or  every  N  MCU
141              blocks  if  "B"  is  attached  to  the  number.  -restart 0 (the
142              default) means no restart markers.
143
144       -smooth N
145              Smooth the input image to eliminate dithering noise.  N, ranging
146              from  1  to  100,  indicates  the strength of smoothing.  0 (the
147              default) means no smoothing.
148
149       -maxmemory N
150              Set limit for amount  of  memory  to  use  in  processing  large
151              images.  Value is in thousands of bytes, or millions of bytes if
152              "M" is attached to the number.  For  example,  -max  4m  selects
153              4000000 bytes.  If more space is needed, temporary files will be
154              used.
155
156       -outfile name
157              Send output image to the named file, not to standard output.
158
159       -verbose
160              Enable debug printout.  More -v's give more output.  Also,  ver‐
161              sion information is printed at startup.
162
163       -debug Same as -verbose.
164
165       The  -restart option inserts extra markers that allow a JPEG decoder to
166       resynchronize after a transmission error.  Without restart markers, any
167       damage  to a compressed file will usually ruin the image from the point
168       of the error to the end of the image; with restart markers, the  damage
169       is  usually confined to the portion of the image up to the next restart
170       marker.  Of course, the restart markers occupy extra space.  We  recom‐
171       mend  -restart  1 for images that will be transmitted across unreliable
172       networks such as Usenet.
173
174       The -smooth option filters the input  to  eliminate  fine-scale  noise.
175       This  is often useful when converting dithered images to JPEG: a moder‐
176       ate smoothing factor of 10 to 50 gets rid of dithering patterns in  the
177       input  file,  resulting  in  a  smaller  JPEG file and a better-looking
178       image.  Too large a smoothing factor will visibly blur the image,  how‐
179       ever.
180
181       Switches for wizards:
182
183       -arithmetic
184              Use  arithmetic  coding.   Caution: arithmetic coded JPEG is not
185              yet widely implemented, so many decoders will be unable to  view
186              an arithmetic coded JPEG file at all.
187
188       -baseline
189              Force  baseline-compatible  quantization tables to be generated.
190              This clamps quantization values to 8 bits even  at  low  quality
191              settings.   (This  switch  is  poorly  named,  since it does not
192              ensure that the output is actually baseline JPEG.  For  example,
193              you can use -baseline and -progressive together.)
194
195       -qtables file
196              Use the quantization tables given in the specified text file.
197
198       -qslots N[,...]
199              Select which quantization table to use for each color component.
200
201       -sample HxV[,...]
202              Set JPEG sampling factors for each color component.
203
204       -scans file
205              Use the scan script given in the specified text file.
206
207       The  "wizard"  switches are intended for experimentation with JPEG.  If
208       you don't know what you are doing, don't use them.  These switches  are
209       documented further in the file wizard.txt.
210

EXAMPLES

212       This  example  compresses the PPM file foo.ppm with a quality factor of
213       60 and saves the output as foo.jpg:
214
215              cjpeg -quality 60 foo.ppm > foo.jpg
216

HINTS

218       Color GIF files are not the  ideal  input  for  JPEG;  JPEG  is  really
219       intended  for  compressing  full-color (24-bit) images.  In particular,
220       don't try to convert cartoons, line drawings,  and  other  images  that
221       have  only  a few distinct colors.  GIF works great on these, JPEG does
222       not.  If you want to convert a GIF to JPEG, you should experiment  with
223       cjpeg's  -quality and -smooth options to get a satisfactory conversion.
224       -smooth 10 or so is often helpful.
225
226       Avoid running an image through a series of JPEG  compression/decompres‐
227       sion  cycles.   Image  quality  loss  will  accumulate; after ten or so
228       cycles the image may be noticeably worse than it was after  one  cycle.
229       It's  best  to  use a lossless format while manipulating an image, then
230       convert to JPEG format when you are ready to file the image away.
231
232       The -optimize option to cjpeg is worth using  when  you  are  making  a
233       "final" version for posting or archiving.  It's also a win when you are
234       using low quality settings to make very small JPEG files; the  percent‐
235       age  improvement  is  often a lot more than it is on larger files.  (At
236       present, -optimize mode is always selected when generating  progressive
237       JPEG files.)
238

ENVIRONMENT

240       JPEGMEM
241              If  this  environment  variable is set, its value is the default
242              memory limit.  The value  is  specified  as  described  for  the
243              -maxmemory  switch.   JPEGMEM overrides the default value speci‐
244              fied when the program was compiled, and itself is overridden  by
245              an explicit -maxmemory.
246

SEE ALSO

248       djpeg(1), jpegtran(1), rdjpgcom(1), wrjpgcom(1)
249       ppm(5), pgm(5)
250       Wallace,  Gregory  K.   "The  JPEG Still Picture Compression Standard",
251       Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44.
252

AUTHOR

254       Independent JPEG Group
255

BUGS

257       Support for GIF input files was removed in cjpeg v6b  due  to  concerns
258       over  the  Unisys  LZW  patent.   Although this patent expired in 2006,
259       cjpeg still lacks GIF support, for these historical reasons.   (Conver‐
260       sion of GIF files to JPEG is usually a bad idea anyway.)
261
262       Not all variants of BMP and Targa file formats are supported.
263
264       The  -targa switch is not a bug, it's a feature.  (It would be a bug if
265       the Targa format designers had not been clueless.)
266
267
268
269                                11 October 2010                       CJPEG(1)
Impressum