1DJPEG(1) General Commands Manual DJPEG(1)
2
3
4
6 djpeg - decompress a JPEG file to an image file
7
9 djpeg [ options ] [ filename ]
10
12 djpeg decompresses the named JPEG file, or the standard input if no
13 file is named, and produces an image file on the standard output. PBM‐
14 PLUS (PPM/PGM), BMP, GIF, or Targa output format can be selected.
15
17 All switch names may be abbreviated; for example, -grayscale may be
18 written -gray or -gr. Most of the "basic" switches can be abbreviated
19 to as little as one letter. Upper and lower case are equivalent (thus
20 -BMP is the same as -bmp). British spellings are also accepted (e.g.,
21 -greyscale), though for brevity these are not mentioned below.
22
23 The basic switches are:
24
25 -colors N
26 Reduce image to at most N colors. This reduces the number of
27 colors used in the output image, so that it can be displayed on
28 a colormapped display or stored in a colormapped file format.
29 For example, if you have an 8-bit display, you'd need to reduce
30 to 256 or fewer colors.
31
32 -quantize N
33 Same as -colors. -colors is the recommended name, -quantize is
34 provided only for backwards compatibility.
35
36 -fast Select recommended processing options for fast, low quality out‐
37 put. (The default options are chosen for highest quality out‐
38 put.) Currently, this is equivalent to -dct fast -nosmooth
39 -onepass -dither ordered.
40
41 -grayscale
42 Force grayscale output even if JPEG file is color. Useful for
43 viewing on monochrome displays; also, djpeg runs noticeably
44 faster in this mode.
45
46 -rgb Force RGB output even if JPEG file is grayscale.
47
48 -scale M/N
49 Scale the output image by a factor M/N. Currently the scale
50 factor must be M/8, where M is an integer between 1 and 16 in‐
51 clusive, or any reduced fraction thereof (such as 1/2, 3/4,
52 etc.) Scaling is handy if the image is larger than your screen;
53 also, djpeg runs much faster when scaling down the output.
54
55 -bmp Select BMP output format (Windows flavor). 8-bit colormapped
56 format is emitted if -colors or -grayscale is specified, or if
57 the JPEG file is grayscale; otherwise, 24-bit full-color format
58 is emitted.
59
60 -gif Select GIF output format (LZW-compressed). Since GIF does not
61 support more than 256 colors, -colors 256 is assumed (unless you
62 specify a smaller number of colors). If you specify -fast, the
63 default number of colors is 216.
64
65 -gif0 Select GIF output format (uncompressed). Since GIF does not
66 support more than 256 colors, -colors 256 is assumed (unless you
67 specify a smaller number of colors). If you specify -fast, the
68 default number of colors is 216.
69
70 -os2 Select BMP output format (OS/2 1.x flavor). 8-bit colormapped
71 format is emitted if -colors or -grayscale is specified, or if
72 the JPEG file is grayscale; otherwise, 24-bit full-color format
73 is emitted.
74
75 -pnm Select PBMPLUS (PPM/PGM) output format (this is the default for‐
76 mat). PGM is emitted if the JPEG file is grayscale or if
77 -grayscale is specified; otherwise PPM is emitted.
78
79 -targa Select Targa output format. Grayscale format is emitted if the
80 JPEG file is grayscale or if -grayscale is specified; otherwise,
81 colormapped format is emitted if -colors is specified; other‐
82 wise, 24-bit full-color format is emitted.
83
84 Switches for advanced users:
85
86 -dct int
87 Use accurate integer DCT method (default).
88
89 -dct fast
90 Use less accurate integer DCT method [legacy feature]. When the
91 Independent JPEG Group's software was first released in 1991,
92 the decompression time for a 1-megapixel JPEG image on a main‐
93 stream PC was measured in minutes. Thus, the fast integer DCT
94 algorithm provided noticeable performance benefits. On modern
95 CPUs running libjpeg-turbo, however, the decompression time for
96 a 1-megapixel JPEG image is measured in milliseconds, and thus
97 the performance benefits of the fast algorithm are much less no‐
98 ticeable. On modern x86/x86-64 CPUs that support AVX2 instruc‐
99 tions, the fast and int methods have similar performance. On
100 other types of CPUs, the fast method is generally about 5-15%
101 faster than the int method.
102
103 If the JPEG image was compressed using a quality level of 85 or
104 below, then there should be little or no perceptible quality
105 difference between the two algorithms. When decompressing im‐
106 ages that were compressed using quality levels above 85, how‐
107 ever, the difference between the fast and int methods becomes
108 more pronounced. With images compressed using quality=97, for
109 instance, the fast method incurs generally about a 4-6 dB loss
110 in PSNR relative to the int method, but this can be larger for
111 some images. If you can avoid it, do not use the fast method
112 when decompressing images that were compressed using quality
113 levels above 97. The algorithm often degenerates for such im‐
114 ages and can actually produce a more lossy output image than if
115 the JPEG image had been compressed using lower quality levels.
116
117 -dct float
118 Use floating-point DCT method [legacy feature]. The float
119 method does not produce significantly more accurate results than
120 the int method, and it is much slower. The float method may
121 also give different results on different machines due to varying
122 roundoff behavior, whereas the integer methods should give the
123 same results on all machines.
124
125 -dither fs
126 Use Floyd-Steinberg dithering in color quantization.
127
128 -dither ordered
129 Use ordered dithering in color quantization.
130
131 -dither none
132 Do not use dithering in color quantization. By default, Floyd-
133 Steinberg dithering is applied when quantizing colors; this is
134 slow but usually produces the best results. Ordered dither is a
135 compromise between speed and quality; no dithering is fast but
136 usually looks awful. Note that these switches have no effect
137 unless color quantization is being done. Ordered dither is only
138 available in -onepass mode.
139
140 -icc file
141 Extract ICC color management profile to the specified file.
142
143 -map file
144 Quantize to the colors used in the specified image file. This
145 is useful for producing multiple files with identical color
146 maps, or for forcing a predefined set of colors to be used. The
147 file must be a GIF or PPM file. This option overrides -colors
148 and -onepass.
149
150 -nosmooth
151 Use a faster, lower-quality upsampling routine.
152
153 -onepass
154 Use one-pass instead of two-pass color quantization. The one-
155 pass method is faster and needs less memory, but it produces a
156 lower-quality image. -onepass is ignored unless you also say
157 -colors N. Also, the one-pass method is always used for
158 grayscale output (the two-pass method is no improvement then).
159
160 -maxmemory N
161 Set limit for amount of memory to use in processing large im‐
162 ages. Value is in thousands of bytes, or millions of bytes if
163 "M" is attached to the number. For example, -max 4m selects
164 4000000 bytes. If more space is needed, an error will occur.
165
166 -maxscans N
167 Abort if the JPEG image contains more than N scans. This fea‐
168 ture demonstrates a method by which applications can guard
169 against denial-of-service attacks instigated by specially-
170 crafted malformed JPEG images containing numerous scans with
171 missing image data or image data consisting only of "EOB runs"
172 (a feature of progressive JPEG images that allows potentially
173 hundreds of thousands of adjoining zero-value pixels to be rep‐
174 resented using only a few bytes.) Attempting to decompress such
175 malformed JPEG images can cause excessive CPU activity, since
176 the decompressor must fully process each scan (even if the scan
177 is corrupt) before it can proceed to the next scan.
178
179 -outfile name
180 Send output image to the named file, not to standard output.
181
182 -memsrc
183 Load input file into memory before decompressing. This feature
184 was implemented mainly as a way of testing the in-memory source
185 manager (jpeg_mem_src().)
186
187 -report
188 Report decompression progress.
189
190 -skip Y0,Y1
191 Decompress all rows of the JPEG image except those between Y0
192 and Y1 (inclusive.) Note that if decompression scaling is being
193 used, then Y0 and Y1 are relative to the scaled image dimen‐
194 sions.
195
196 -crop WxH+X+Y
197 Decompress only a rectangular subregion of the image, starting
198 at point X,Y with width W and height H. If necessary, X will be
199 shifted left to the nearest iMCU boundary, and the width will be
200 increased accordingly. Note that if decompression scaling is
201 being used, then X, Y, W, and H are relative to the scaled image
202 dimensions. Currently this option only works with the PBMPLUS
203 (PPM/PGM), GIF, and Targa output formats.
204
205 -strict
206 Treat all warnings as fatal. This feature also demonstrates a
207 method by which applications can guard against attacks insti‐
208 gated by specially-crafted malformed JPEG images. Enabling this
209 option will cause the decompressor to abort if the JPEG image
210 contains incomplete or corrupt image data.
211
212 -verbose
213 Enable debug printout. More -v's give more output. Also, ver‐
214 sion information is printed at startup.
215
216 -debug Same as -verbose.
217
218 -version
219 Print version information and exit.
220
222 This example decompresses the JPEG file foo.jpg, quantizes it to 256
223 colors, and saves the output in 8-bit BMP format in foo.bmp:
224
225 djpeg -colors 256 -bmp foo.jpg > foo.bmp
226
228 To get a quick preview of an image, use the -grayscale and/or -scale
229 switches. -grayscale -scale 1/8 is the fastest case.
230
231 Several options are available that trade off image quality to gain
232 speed. -fast turns on the recommended settings.
233
234 -dct fast and/or -nosmooth gain speed at a small sacrifice in quality.
235 When producing a color-quantized image, -onepass -dither ordered is
236 fast but much lower quality than the default behavior. -dither none
237 may give acceptable results in two-pass mode, but is seldom tolerable
238 in one-pass mode.
239
241 JPEGMEM
242 If this environment variable is set, its value is the default
243 memory limit. The value is specified as described for the
244 -maxmemory switch. JPEGMEM overrides the default value speci‐
245 fied when the program was compiled, and itself is overridden by
246 an explicit -maxmemory.
247
249 cjpeg(1), jpegtran(1), rdjpgcom(1), wrjpgcom(1)
250 ppm(5), pgm(5)
251 Wallace, Gregory K. "The JPEG Still Picture Compression Standard",
252 Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44.
253
255 Independent JPEG Group
256
257 This file was modified by The libjpeg-turbo Project to include only in‐
258 formation relevant to libjpeg-turbo, to wordsmith certain sections, and
259 to describe features not present in libjpeg.
260
261
262
263 4 November 2020 DJPEG(1)