1 .TH JPEGTRAN 1 "31 January 2012"
3 jpegtran \- lossless transformation of JPEG files
16 performs various useful transformations of JPEG files.
17 It can translate the coded representation from one variant of JPEG to another,
18 for example from baseline JPEG to progressive JPEG or vice versa. It can also
19 perform some rearrangements of the image data, for example turning an image
20 from landscape to portrait format by rotation.
23 works by rearranging the compressed data (DCT coefficients), without
24 ever fully decoding the image. Therefore, its transformations are lossless:
25 there is no image degradation at all, which would not be true if you used
29 to accomplish the same conversion. But by the same token,
31 cannot perform lossy operations such as changing the image quality.
34 reads the named JPEG/JFIF file, or the standard input if no file is
35 named, and produces a JPEG/JFIF file on the standard output.
37 All switch names may be abbreviated; for example,
43 Upper and lower case are equivalent.
44 British spellings are also accepted (e.g.,
46 though for brevity these are not mentioned below.
48 To specify the coded JPEG representation used in the output file,
50 accepts a subset of the switches recognized by
54 Perform optimization of entropy encoding parameters.
57 Create progressive JPEG file.
60 Emit a JPEG restart marker every N MCU rows, or every N MCU blocks if "B" is
61 attached to the number.
64 Use arithmetic coding.
67 Use the scan script given in the specified text file.
71 for more details about these switches.
72 If you specify none of these switches, you get a plain baseline-JPEG output
73 file. The quality setting and so forth are determined by the input file.
75 The image can be losslessly transformed by giving one of these switches:
78 Mirror image horizontally (left-right).
81 Mirror image vertically (top-bottom).
84 Rotate image 90 degrees clockwise.
87 Rotate image 180 degrees.
90 Rotate image 270 degrees clockwise (or 90 ccw).
93 Transpose image (across UL-to-LR axis).
96 Transverse transpose (across UR-to-LL axis).
98 The transpose transformation has no restrictions regarding image dimensions.
99 The other transformations operate rather oddly if the image dimensions are not
100 a multiple of the iMCU size (usually 8 or 16 pixels), because they can only
101 transform complete blocks of DCT coefficient data in the desired way.
104 default behavior when transforming an odd-size image is designed
105 to preserve exact reversibility and mathematical consistency of the
106 transformation set. As stated, transpose is able to flip the entire image
107 area. Horizontal mirroring leaves any partial iMCU column at the right edge
108 untouched, but is able to flip all rows of the image. Similarly, vertical
109 mirroring leaves any partial iMCU row at the bottom edge untouched, but is
110 able to flip all columns. The other transforms can be built up as sequences
111 of transpose and flip operations; for consistency, their actions on edge
112 pixels are defined to be the same as the end result of the corresponding
113 transpose-and-flip sequence.
115 For practical use, you may prefer to discard any untransformable edge pixels
116 rather than having a strange-looking strip along the right and/or bottom edges
117 of a transformed image. To do this, add the
122 Drop non-transformable edge blocks.
124 Obviously, a transformation with
126 is not reversible, so strictly speaking
128 with this switch is not lossless. Also, the expected mathematical
129 equivalences between the transformations no longer hold. For example,
131 trims only the bottom edge, but
138 If you are only interested in perfect transformations, add the
142 to fail with an error if the transformation is not perfect.
144 For example, you may want to do
146 .B (jpegtran \-rot 90 -perfect
150 .B | pnmflip \-r90 | cjpeg)
152 to do a perfect rotation, if available, or an approximated one if not.
155 Crop the image to a rectangular region of width W and height H, starting at
156 point X,Y. The lossless crop feature discards data outside of a given image
157 region but losslessly preserves what is inside. Like the rotate and flip
158 transforms, lossless crop is restricted by the current JPEG format; the upper
159 left corner of the selected region must fall on an iMCU boundary. If it
160 doesn't, then it is silently moved up and/or left to the nearest iMCU boundary
161 (the lower right corner is unchanged.)
163 Other not-strictly-lossless transformation switches are:
166 Force grayscale output.
168 This option discards the chrominance channels if the input image is YCbCr
169 (ie, a standard color JPEG), resulting in a grayscale JPEG file. The
170 luminance channel is preserved exactly, so this is a better method of reducing
171 to grayscale than decompression, conversion, and recompression. This switch
172 is particularly handy for fixing a monochrome picture that was mistakenly
173 encoded as a color JPEG. (In such a case, the space savings from getting rid
174 of the near-empty chroma channels won't be large; but the decoding time for
175 a grayscale JPEG is substantially less than that for a color JPEG.)
178 also recognizes these switches that control what to do with "extra" markers,
179 such as comment blocks:
182 Copy no extra markers from source file. This setting suppresses all
183 comments and other excess baggage present in the source file.
186 Copy only comment markers. This setting copies comments from the source file
187 but discards any other data that is inessential for image display.
190 Copy all extra markers. This setting preserves miscellaneous markers
191 found in the source file, such as JFIF thumbnails, Exif data, and Photoshop
192 settings. In some files, these extra markers can be sizable.
194 The default behavior is \fB-copy comments\fR. (Note: in IJG releases v6 and
195 v6a, \fBjpegtran\fR always did the equivalent of \fB-copy none\fR.)
197 Additional switches recognized by jpegtran are:
200 Set limit for amount of memory to use in processing large images. Value is
201 in thousands of bytes, or millions of bytes if "M" is attached to the
204 selects 4000000 bytes. If more space is needed, temporary files will be used.
206 .BI \-outfile " name"
207 Send output image to the named file, not to standard output.
210 Enable debug printout. More
212 give more output. Also, version information is printed at startup.
219 This example converts a baseline JPEG file to progressive form:
221 .B jpegtran \-progressive
226 This example rotates an image 90 degrees clockwise, discarding any
227 unrotatable edge pixels:
229 .B jpegtran \-rot 90 -trim
236 If this environment variable is set, its value is the default memory limit.
237 The value is specified as described for the
241 overrides the default value specified when the program was compiled, and
242 itself is overridden by an explicit
250 Wallace, Gregory K. "The JPEG Still Picture Compression Standard",
251 Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44.
253 Independent JPEG Group
255 The transform options can't transform odd-size images perfectly. Use
259 if you don't like the results.
261 The entire image is read into memory and then written out again, even in
262 cases where this isn't really necessary. Expect swapping on large images,
263 especially when using the more complex transform options.