jpayne@68
|
1 .TH JPEGTRAN 1 "28 August 2019"
|
jpayne@68
|
2 .SH NAME
|
jpayne@68
|
3 jpegtran \- lossless transformation of JPEG files
|
jpayne@68
|
4 .SH SYNOPSIS
|
jpayne@68
|
5 .B jpegtran
|
jpayne@68
|
6 [
|
jpayne@68
|
7 .I options
|
jpayne@68
|
8 ]
|
jpayne@68
|
9 [
|
jpayne@68
|
10 .I filename
|
jpayne@68
|
11 ]
|
jpayne@68
|
12 .LP
|
jpayne@68
|
13 .SH DESCRIPTION
|
jpayne@68
|
14 .LP
|
jpayne@68
|
15 .B jpegtran
|
jpayne@68
|
16 performs various useful transformations of JPEG files.
|
jpayne@68
|
17 It can translate the coded representation from one variant of JPEG to another,
|
jpayne@68
|
18 for example from baseline JPEG to progressive JPEG or vice versa. It can also
|
jpayne@68
|
19 perform some rearrangements of the image data, for example turning an image
|
jpayne@68
|
20 from landscape to portrait format by rotation.
|
jpayne@68
|
21 .PP
|
jpayne@68
|
22 For EXIF files and JPEG files containing Exif data, you may prefer to use
|
jpayne@68
|
23 .B exiftran
|
jpayne@68
|
24 instead.
|
jpayne@68
|
25 .PP
|
jpayne@68
|
26 .B jpegtran
|
jpayne@68
|
27 works by rearranging the compressed data (DCT coefficients), without
|
jpayne@68
|
28 ever fully decoding the image. Therefore, its transformations are lossless:
|
jpayne@68
|
29 there is no image degradation at all, which would not be true if you used
|
jpayne@68
|
30 .B djpeg
|
jpayne@68
|
31 followed by
|
jpayne@68
|
32 .B cjpeg
|
jpayne@68
|
33 to accomplish the same conversion. But by the same token,
|
jpayne@68
|
34 .B jpegtran
|
jpayne@68
|
35 cannot perform lossy operations such as changing the image quality. However,
|
jpayne@68
|
36 while the image data is losslessly transformed, metadata can be removed. See
|
jpayne@68
|
37 the
|
jpayne@68
|
38 .B \-copy
|
jpayne@68
|
39 option for specifics.
|
jpayne@68
|
40 .PP
|
jpayne@68
|
41 .B jpegtran
|
jpayne@68
|
42 reads the named JPEG/JFIF file, or the standard input if no file is
|
jpayne@68
|
43 named, and produces a JPEG/JFIF file on the standard output.
|
jpayne@68
|
44 .SH OPTIONS
|
jpayne@68
|
45 All switch names may be abbreviated; for example,
|
jpayne@68
|
46 .B \-optimize
|
jpayne@68
|
47 may be written
|
jpayne@68
|
48 .B \-opt
|
jpayne@68
|
49 or
|
jpayne@68
|
50 .BR \-o .
|
jpayne@68
|
51 Upper and lower case are equivalent.
|
jpayne@68
|
52 British spellings are also accepted (e.g.,
|
jpayne@68
|
53 .BR \-optimise ),
|
jpayne@68
|
54 though for brevity these are not mentioned below.
|
jpayne@68
|
55 .PP
|
jpayne@68
|
56 To specify the coded JPEG representation used in the output file,
|
jpayne@68
|
57 .B jpegtran
|
jpayne@68
|
58 accepts a subset of the switches recognized by
|
jpayne@68
|
59 .BR cjpeg :
|
jpayne@68
|
60 .TP
|
jpayne@68
|
61 .B \-optimize
|
jpayne@68
|
62 Perform optimization of entropy encoding parameters.
|
jpayne@68
|
63 .TP
|
jpayne@68
|
64 .B \-progressive
|
jpayne@68
|
65 Create progressive JPEG file.
|
jpayne@68
|
66 .TP
|
jpayne@68
|
67 .BI \-restart " N"
|
jpayne@68
|
68 Emit a JPEG restart marker every N MCU rows, or every N MCU blocks if "B" is
|
jpayne@68
|
69 attached to the number.
|
jpayne@68
|
70 .TP
|
jpayne@68
|
71 .B \-arithmetic
|
jpayne@68
|
72 Use arithmetic coding.
|
jpayne@68
|
73 .TP
|
jpayne@68
|
74 .BI \-scans " file"
|
jpayne@68
|
75 Use the scan script given in the specified text file.
|
jpayne@68
|
76 .PP
|
jpayne@68
|
77 See
|
jpayne@68
|
78 .BR cjpeg (1)
|
jpayne@68
|
79 for more details about these switches.
|
jpayne@68
|
80 If you specify none of these switches, you get a plain baseline-JPEG output
|
jpayne@68
|
81 file. The quality setting and so forth are determined by the input file.
|
jpayne@68
|
82 .PP
|
jpayne@68
|
83 The image can be losslessly transformed by giving one of these switches:
|
jpayne@68
|
84 .TP
|
jpayne@68
|
85 .B \-flip horizontal
|
jpayne@68
|
86 Mirror image horizontally (left-right).
|
jpayne@68
|
87 .TP
|
jpayne@68
|
88 .B \-flip vertical
|
jpayne@68
|
89 Mirror image vertically (top-bottom).
|
jpayne@68
|
90 .TP
|
jpayne@68
|
91 .B \-rotate 90
|
jpayne@68
|
92 Rotate image 90 degrees clockwise.
|
jpayne@68
|
93 .TP
|
jpayne@68
|
94 .B \-rotate 180
|
jpayne@68
|
95 Rotate image 180 degrees.
|
jpayne@68
|
96 .TP
|
jpayne@68
|
97 .B \-rotate 270
|
jpayne@68
|
98 Rotate image 270 degrees clockwise (or 90 ccw).
|
jpayne@68
|
99 .TP
|
jpayne@68
|
100 .B \-transpose
|
jpayne@68
|
101 Transpose image (across UL-to-LR axis).
|
jpayne@68
|
102 .TP
|
jpayne@68
|
103 .B \-transverse
|
jpayne@68
|
104 Transverse transpose (across UR-to-LL axis).
|
jpayne@68
|
105 .IP
|
jpayne@68
|
106 The transpose transformation has no restrictions regarding image dimensions.
|
jpayne@68
|
107 The other transformations operate rather oddly if the image dimensions are not
|
jpayne@68
|
108 a multiple of the iMCU size (usually 8 or 16 pixels), because they can only
|
jpayne@68
|
109 transform complete blocks of DCT coefficient data in the desired way.
|
jpayne@68
|
110 .IP
|
jpayne@68
|
111 .BR jpegtran 's
|
jpayne@68
|
112 default behavior when transforming an odd-size image is designed
|
jpayne@68
|
113 to preserve exact reversibility and mathematical consistency of the
|
jpayne@68
|
114 transformation set. As stated, transpose is able to flip the entire image
|
jpayne@68
|
115 area. Horizontal mirroring leaves any partial iMCU column at the right edge
|
jpayne@68
|
116 untouched, but is able to flip all rows of the image. Similarly, vertical
|
jpayne@68
|
117 mirroring leaves any partial iMCU row at the bottom edge untouched, but is
|
jpayne@68
|
118 able to flip all columns. The other transforms can be built up as sequences
|
jpayne@68
|
119 of transpose and flip operations; for consistency, their actions on edge
|
jpayne@68
|
120 pixels are defined to be the same as the end result of the corresponding
|
jpayne@68
|
121 transpose-and-flip sequence.
|
jpayne@68
|
122 .IP
|
jpayne@68
|
123 For practical use, you may prefer to discard any untransformable edge pixels
|
jpayne@68
|
124 rather than having a strange-looking strip along the right and/or bottom edges
|
jpayne@68
|
125 of a transformed image. To do this, add the
|
jpayne@68
|
126 .B \-trim
|
jpayne@68
|
127 switch:
|
jpayne@68
|
128 .TP
|
jpayne@68
|
129 .B \-trim
|
jpayne@68
|
130 Drop non-transformable edge blocks.
|
jpayne@68
|
131 .IP
|
jpayne@68
|
132 Obviously, a transformation with
|
jpayne@68
|
133 .B \-trim
|
jpayne@68
|
134 is not reversible, so strictly speaking
|
jpayne@68
|
135 .B jpegtran
|
jpayne@68
|
136 with this switch is not lossless. Also, the expected mathematical
|
jpayne@68
|
137 equivalences between the transformations no longer hold. For example,
|
jpayne@68
|
138 .B \-rot 270 -trim
|
jpayne@68
|
139 trims only the bottom edge, but
|
jpayne@68
|
140 .B \-rot 90 -trim
|
jpayne@68
|
141 followed by
|
jpayne@68
|
142 .B \-rot 180 -trim
|
jpayne@68
|
143 trims both edges.
|
jpayne@68
|
144 .IP
|
jpayne@68
|
145 If you are only interested in perfect transformation, add the
|
jpayne@68
|
146 .B \-perfect
|
jpayne@68
|
147 switch:
|
jpayne@68
|
148 .TP
|
jpayne@68
|
149 .B \-perfect
|
jpayne@68
|
150 Fails with an error if the transformation is not perfect.
|
jpayne@68
|
151 .IP
|
jpayne@68
|
152 For example you may want to do
|
jpayne@68
|
153 .IP
|
jpayne@68
|
154 .B (jpegtran \-rot 90 -perfect
|
jpayne@68
|
155 .I foo.jpg
|
jpayne@68
|
156 .B || djpeg
|
jpayne@68
|
157 .I foo.jpg
|
jpayne@68
|
158 .B | pnmflip \-r90 | cjpeg)
|
jpayne@68
|
159 .IP
|
jpayne@68
|
160 to do a perfect rotation if available or an approximated one if not.
|
jpayne@68
|
161 .PP
|
jpayne@68
|
162 We also offer a lossless-crop option, which discards data outside a given
|
jpayne@68
|
163 image region but losslessly preserves what is inside. Like the rotate and
|
jpayne@68
|
164 flip transforms, lossless crop is restricted by the current JPEG format: the
|
jpayne@68
|
165 upper left corner of the selected region must fall on an iMCU boundary. If
|
jpayne@68
|
166 this does not hold for the given crop parameters, we silently move the upper
|
jpayne@68
|
167 left corner up and/or left to make it so, simultaneously increasing the
|
jpayne@68
|
168 region dimensions to keep the lower right crop corner unchanged. (Thus, the
|
jpayne@68
|
169 output image covers at least the requested region, but may cover more.)
|
jpayne@68
|
170 The adjustment of the region dimensions may be optionally disabled by
|
jpayne@68
|
171 attaching an 'f' character ("force") to the width or height number.
|
jpayne@68
|
172 .PP
|
jpayne@68
|
173 The image can be losslessly cropped by giving the switch:
|
jpayne@68
|
174 .TP
|
jpayne@68
|
175 .B \-crop WxH+X+Y
|
jpayne@68
|
176 Crop to a rectangular subarea of width W, height H starting at point X,Y.
|
jpayne@68
|
177 .PP
|
jpayne@68
|
178 Crop extension: The width or height parameters can be made larger than the
|
jpayne@68
|
179 source image. In this case the extra area is filled in with zero (neutral
|
jpayne@68
|
180 gray). A larger width parameter has two more options: Attaching an 'f'
|
jpayne@68
|
181 character ("flatten") to the width number will fill in the extra area with
|
jpayne@68
|
182 the DC of the adjacent block, instead of gray out. Attaching an 'r'
|
jpayne@68
|
183 character ("reflect") to the width number will fill in the extra area with
|
jpayne@68
|
184 repeated reflections of the source region, instead of gray out.
|
jpayne@68
|
185 .PP
|
jpayne@68
|
186 A complementary lossless-wipe option is provided to discard (gray out) data
|
jpayne@68
|
187 inside a given image region while losslessly preserving what is outside:
|
jpayne@68
|
188 .TP
|
jpayne@68
|
189 .B \-wipe WxH+X+Y
|
jpayne@68
|
190 Wipe (gray out) a rectangular subarea of width W, height H starting at point
|
jpayne@68
|
191 X,Y.
|
jpayne@68
|
192 .PP
|
jpayne@68
|
193 Attaching an 'f' character ("flatten") to the width number will fill the
|
jpayne@68
|
194 region with the average of adjacent blocks, instead of gray out. In case
|
jpayne@68
|
195 the wipe region and outside area form two horizontally adjacent rectangles,
|
jpayne@68
|
196 attaching an 'r' character ("reflect") to the width number will fill the
|
jpayne@68
|
197 region with repeated reflections of the outside area, instead of gray out.
|
jpayne@68
|
198 .PP
|
jpayne@68
|
199 Another option is lossless-drop, which replaces data at a given image
|
jpayne@68
|
200 position by another image:
|
jpayne@68
|
201 .TP
|
jpayne@68
|
202 .B \-drop +X+Y filename
|
jpayne@68
|
203 Drop another image
|
jpayne@68
|
204 .PP
|
jpayne@68
|
205 Both source images must have the same subsampling values. It is best if
|
jpayne@68
|
206 they also have the same quantization, otherwise quantization adaption occurs.
|
jpayne@68
|
207 The trim option can be used with the drop option to requantize the drop file
|
jpayne@68
|
208 to the source file.
|
jpayne@68
|
209 .PP
|
jpayne@68
|
210 Other not-strictly-lossless transformation switches are:
|
jpayne@68
|
211 .TP
|
jpayne@68
|
212 .B \-grayscale
|
jpayne@68
|
213 Force grayscale output.
|
jpayne@68
|
214 .IP
|
jpayne@68
|
215 This option discards the chrominance channels if the input image is YCbCr
|
jpayne@68
|
216 (ie, a standard color JPEG), resulting in a grayscale JPEG file. The
|
jpayne@68
|
217 luminance channel is preserved exactly, so this is a better method of reducing
|
jpayne@68
|
218 to grayscale than decompression, conversion, and recompression. This switch
|
jpayne@68
|
219 is particularly handy for fixing a monochrome picture that was mistakenly
|
jpayne@68
|
220 encoded as a color JPEG. (In such a case, the space savings from getting rid
|
jpayne@68
|
221 of the near-empty chroma channels won't be large; but the decoding time for
|
jpayne@68
|
222 a grayscale JPEG is substantially less than that for a color JPEG.)
|
jpayne@68
|
223 .TP
|
jpayne@68
|
224 .BI \-scale " M/N"
|
jpayne@68
|
225 Scale the output image by a factor M/N.
|
jpayne@68
|
226 .IP
|
jpayne@68
|
227 Currently supported scale factors are M/N with all M from 1 to 16, where N is
|
jpayne@68
|
228 the source DCT size, which is 8 for baseline JPEG. If the /N part is omitted,
|
jpayne@68
|
229 then M specifies the DCT scaled size to be applied on the given input. For
|
jpayne@68
|
230 baseline JPEG this is equivalent to M/8 scaling, since the source DCT size
|
jpayne@68
|
231 for baseline JPEG is 8.
|
jpayne@68
|
232 .B Caution:
|
jpayne@68
|
233 An implementation of the JPEG SmartScale extension is required for this
|
jpayne@68
|
234 feature. SmartScale enabled JPEG is not yet widely implemented, so many
|
jpayne@68
|
235 decoders will be unable to view a SmartScale extended JPEG file at all.
|
jpayne@68
|
236 .PP
|
jpayne@68
|
237 .B jpegtran
|
jpayne@68
|
238 also recognizes these switches that control what to do with "extra" markers,
|
jpayne@68
|
239 such as comment blocks:
|
jpayne@68
|
240 .TP
|
jpayne@68
|
241 .B \-copy none
|
jpayne@68
|
242 Copy no extra markers from source file. This setting suppresses all
|
jpayne@68
|
243 comments and other metadata in the source file.
|
jpayne@68
|
244 .TP
|
jpayne@68
|
245 .B \-copy comments
|
jpayne@68
|
246 Copy only comment markers. This setting copies comments from the source file,
|
jpayne@68
|
247 but discards any other metadata.
|
jpayne@68
|
248 .TP
|
jpayne@68
|
249 .B \-copy all
|
jpayne@68
|
250 Copy all extra markers. This setting preserves metadata
|
jpayne@68
|
251 found in the source file, such as JFIF thumbnails, Exif data, and Photoshop
|
jpayne@68
|
252 settings. In some files these extra markers can be sizable. Note that this
|
jpayne@68
|
253 option will copy thumbnails as-is; they will not be transformed.
|
jpayne@68
|
254 .IP
|
jpayne@68
|
255 The default behavior is
|
jpayne@68
|
256 .BR "\-copy comments" .
|
jpayne@68
|
257 (Note: in IJG releases v6 and v6a,
|
jpayne@68
|
258 .B jpegtran
|
jpayne@68
|
259 always did the equivalent of
|
jpayne@68
|
260 .BR "\-copy none" .)
|
jpayne@68
|
261 .PP
|
jpayne@68
|
262 Additional switches recognized by jpegtran are:
|
jpayne@68
|
263 .TP
|
jpayne@68
|
264 .BI \-maxmemory " N"
|
jpayne@68
|
265 Set limit for amount of memory to use in processing large images. Value is
|
jpayne@68
|
266 in thousands of bytes, or millions of bytes if "M" is attached to the
|
jpayne@68
|
267 number. For example,
|
jpayne@68
|
268 .B \-max 4m
|
jpayne@68
|
269 selects 4000000 bytes. If more space is needed, temporary files will be used.
|
jpayne@68
|
270 .TP
|
jpayne@68
|
271 .BI \-outfile " name"
|
jpayne@68
|
272 Send output image to the named file, not to standard output.
|
jpayne@68
|
273 .TP
|
jpayne@68
|
274 .B \-verbose
|
jpayne@68
|
275 Enable debug printout. More
|
jpayne@68
|
276 .BR \-v 's
|
jpayne@68
|
277 give more output. Also, version information is printed at startup.
|
jpayne@68
|
278 .TP
|
jpayne@68
|
279 .B \-debug
|
jpayne@68
|
280 Same as
|
jpayne@68
|
281 .BR \-verbose .
|
jpayne@68
|
282 .SH EXAMPLES
|
jpayne@68
|
283 .LP
|
jpayne@68
|
284 This example converts a baseline JPEG file to progressive form:
|
jpayne@68
|
285 .IP
|
jpayne@68
|
286 .B jpegtran \-progressive
|
jpayne@68
|
287 .I foo.jpg
|
jpayne@68
|
288 .B >
|
jpayne@68
|
289 .I fooprog.jpg
|
jpayne@68
|
290 .PP
|
jpayne@68
|
291 This example rotates an image 90 degrees clockwise, discarding any
|
jpayne@68
|
292 unrotatable edge pixels:
|
jpayne@68
|
293 .IP
|
jpayne@68
|
294 .B jpegtran \-rot 90 -trim
|
jpayne@68
|
295 .I foo.jpg
|
jpayne@68
|
296 .B >
|
jpayne@68
|
297 .I foo90.jpg
|
jpayne@68
|
298 .SH ENVIRONMENT
|
jpayne@68
|
299 .TP
|
jpayne@68
|
300 .B JPEGMEM
|
jpayne@68
|
301 If this environment variable is set, its value is the default memory limit.
|
jpayne@68
|
302 The value is specified as described for the
|
jpayne@68
|
303 .B \-maxmemory
|
jpayne@68
|
304 switch.
|
jpayne@68
|
305 .B JPEGMEM
|
jpayne@68
|
306 overrides the default value specified when the program was compiled, and
|
jpayne@68
|
307 itself is overridden by an explicit
|
jpayne@68
|
308 .BR \-maxmemory .
|
jpayne@68
|
309 .SH SEE ALSO
|
jpayne@68
|
310 .BR cjpeg (1),
|
jpayne@68
|
311 .BR djpeg (1),
|
jpayne@68
|
312 .BR rdjpgcom (1),
|
jpayne@68
|
313 .BR wrjpgcom (1)
|
jpayne@68
|
314 .br
|
jpayne@68
|
315 Wallace, Gregory K. "The JPEG Still Picture Compression Standard",
|
jpayne@68
|
316 Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44.
|
jpayne@68
|
317 .SH AUTHOR
|
jpayne@68
|
318 Independent JPEG Group
|
jpayne@68
|
319 .SH BUGS
|
jpayne@68
|
320 The transform options can't transform odd-size images perfectly. Use
|
jpayne@68
|
321 .B \-trim
|
jpayne@68
|
322 or
|
jpayne@68
|
323 .B \-perfect
|
jpayne@68
|
324 if you don't like the results.
|
jpayne@68
|
325 .PP
|
jpayne@68
|
326 The entire image is read into memory and then written out again, even in
|
jpayne@68
|
327 cases where this isn't really necessary. Expect swapping on large images,
|
jpayne@68
|
328 especially when using the more complex transform options.
|