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

NAME

6       jpegtran - lossless transformation of JPEG files
7

SYNOPSIS

9       jpegtran [ options ] [ filename ]
10

DESCRIPTION

12       jpegtran performs various useful transformations of JPEG files.  It can
13       translate the coded representation from one variant of JPEG to another,
14       for  example  from baseline JPEG to progressive JPEG or vice versa.  It
15       can also perform some rearrangements of the  image  data,  for  example
16       turning an image from landscape to portrait format by rotation.
17
18       For  EXIF  files and JPEG files containing Exif data, you may prefer to
19       use exiftran instead.
20
21       jpegtran works by rearranging the compressed data  (DCT  coefficients),
22       without  ever fully decoding the image.  Therefore, its transformations
23       are lossless: there is no image degradation at all, which would not  be
24       true if you used djpeg followed by cjpeg to accomplish the same conver‐
25       sion.  But by the same token, jpegtran cannot perform lossy  operations
26       such  as  changing the image quality.  However, while the image data is
27       losslessly transformed, metadata can be removed.  See the -copy  option
28       for specifics.
29
30       jpegtran  reads  the  named JPEG/JFIF file, or the standard input if no
31       file is named, and produces a JPEG/JFIF file on the standard output.
32

OPTIONS

34       All switch names may be abbreviated;  for  example,  -optimize  may  be
35       written  -opt  or  -o.   Upper  and lower case are equivalent.  British
36       spellings are also accepted (e.g., -optimise), though for brevity these
37       are not mentioned below.
38
39       To specify the coded JPEG representation used in the output file, jpeg‐
40       tran accepts a subset of the switches recognized by cjpeg:
41
42       -optimize
43              Perform optimization of entropy encoding parameters.
44
45       -progressive
46              Create progressive JPEG file.
47
48       -restart N
49              Emit a JPEG restart marker every N MCU  rows,  or  every  N  MCU
50              blocks if "B" is attached to the number.
51
52       -arithmetic
53              Use arithmetic coding.
54
55       -scans file
56              Use the scan script given in the specified text file.
57
58       See  cjpeg(1)  for  more  details about these switches.  If you specify
59       none of these switches, you get a plain baseline-JPEG output file.  The
60       quality setting and so forth are determined by the input file.
61
62       The  image  can  be  losslessly  transformed  by  giving  one  of these
63       switches:
64
65       -flip horizontal
66              Mirror image horizontally (left-right).
67
68       -flip vertical
69              Mirror image vertically (top-bottom).
70
71       -rotate 90
72              Rotate image 90 degrees clockwise.
73
74       -rotate 180
75              Rotate image 180 degrees.
76
77       -rotate 270
78              Rotate image 270 degrees clockwise (or 90 ccw).
79
80       -transpose
81              Transpose image (across UL-to-LR axis).
82
83       -transverse
84              Transverse transpose (across UR-to-LL axis).
85
86       The transpose transformation has no restrictions regarding image dimen‐
87       sions.   The  other  transformations  operate rather oddly if the image
88       dimensions are not a multiple of the iMCU size (usually 8  or  16  pix‐
89       els),  because  they  can only transform complete blocks of DCT coeffi‐
90       cient data in the desired way.
91
92       jpegtran's default behavior when  transforming  an  odd-size  image  is
93       designed  to  preserve exact reversibility and mathematical consistency
94       of the transformation set.  As stated, transpose is able  to  flip  the
95       entire image area.  Horizontal mirroring leaves any partial iMCU column
96       at the right edge untouched, but is able to flip all rows of the image.
97       Similarly, vertical mirroring leaves any partial iMCU row at the bottom
98       edge untouched, but is able to flip all columns.  The other  transforms
99       can be built up as sequences of transpose and flip operations; for con‐
100       sistency, their actions on edge pixels are defined to be  the  same  as
101       the end result of the corresponding transpose-and-flip sequence.
102
103       For  practical  use, you may prefer to discard any untransformable edge
104       pixels rather than having  a  strange-looking  strip  along  the  right
105       and/or  bottom edges of a transformed image.  To do this, add the -trim
106       switch:
107
108       -trim  Drop non-transformable edge blocks.
109
110              Obviously, a transformation with -trim  is  not  reversible,  so
111              strictly  speaking  jpegtran  with  this switch is not lossless.
112              Also, the expected mathematical equivalences between the  trans‐
113              formations  no  longer  hold.  For example, -rot 270 -trim trims
114              only the bottom edge, but -rot 90 -trim  followed  by  -rot  180
115              -trim trims both edges.
116
117       -perfect
118              If  you  are only interested in perfect transformations, add the
119              -perfect switch.  This causes jpegtran to fail with an error  if
120              the transformation is not perfect.
121
122              For example, you may want to do
123
124              (jpegtran  -rot  90  -perfect foo.jpg || djpeg foo.jpg | pnmflip
125              -r90 | cjpeg)
126
127              to do a perfect rotation, if available, or an  approximated  one
128              if not.
129
130       This version of jpegtran also offers a lossless crop option, which dis‐
131       cards data outside of a given image  region  but  losslessly  preserves
132       what  is  inside. Like the rotate and flip transforms, lossless crop is
133       restricted by the current JPEG format; the upper  left  corner  of  the
134       selected  region must fall on an iMCU boundary.  If it doesn't, then it
135       is silently moved up and/or left to  the  nearest  iMCU  boundary  (the
136       lower  right  corner  is  unchanged.)  Thus, the output image covers at
137       least the requested region, but it may cover more.  The  adjustment  of
138       the  region  dimensions  may be optionally disabled by attaching an 'f'
139       character ("force") to the width or height number.
140
141       The image can be losslessly cropped by giving the switch:
142
143       -crop WxH+X+Y
144              Crop the image to a rectangular region of width W and height  H,
145              starting  at point X,Y.  The lossless crop feature discards data
146              outside of a given image region but losslessly preserves what is
147              inside.   Like  the rotate and flip transforms, lossless crop is
148              restricted by the current JPEG format; the upper left corner  of
149              the  selected  region  must  fall  on  an  iMCU boundary.  If it
150              doesn't, then it is silently moved up and/or left to the nearest
151              iMCU boundary (the lower right corner is unchanged.)
152
153       Other not-strictly-lossless transformation switches are:
154
155       -grayscale
156              Force grayscale output.
157
158              This option discards the chrominance channels if the input image
159              is YCbCr (ie, a standard color JPEG), resulting in  a  grayscale
160              JPEG  file.  The luminance channel is preserved exactly, so this
161              is a better method of reducing to grayscale than  decompression,
162              conversion,  and  recompression.   This  switch  is particularly
163              handy for  fixing  a  monochrome  picture  that  was  mistakenly
164              encoded  as  a  color  JPEG.  (In such a case, the space savings
165              from getting rid of the  near-empty  chroma  channels  won't  be
166              large;  but  the  decoding time for a grayscale JPEG is substan‐
167              tially less than that for a color JPEG.)
168
169       jpegtran also recognizes these switches that control what  to  do  with
170       "extra" markers, such as comment blocks:
171
172       -copy none
173              Copy no extra markers from source file.  This setting suppresses
174              all comments and other metadata in the source file.
175
176       -copy comments
177              Copy only comment markers.  This setting  copies  comments  from
178              the source file but discards any other metadata.
179
180       -copy all
181              Copy  all  extra  markers.  This setting preserves miscellaneous
182              markers found in the source file, such as JFIF thumbnails,  Exif
183              data,  and Photoshop settings.  In some files, these extra mark‐
184              ers can be sizable.  Note that this option will copy  thumbnails
185              as-is; they will not be transformed.
186
187       The  default behavior is -copy comments.  (Note: in IJG releases v6 and
188       v6a, jpegtran always did the equivalent of -copy none.)
189
190       Additional switches recognized by jpegtran are:
191
192       -maxmemory N
193              Set limit for amount  of  memory  to  use  in  processing  large
194              images.  Value is in thousands of bytes, or millions of bytes if
195              "M" is attached to the number.  For  example,  -max  4m  selects
196              4000000 bytes.  If more space is needed, an error will occur.
197
198       -outfile name
199              Send output image to the named file, not to standard output.
200
201       -verbose
202              Enable  debug printout.  More -v's give more output.  Also, ver‐
203              sion information is printed at startup.
204
205       -debug Same as -verbose.
206
207       -version
208              Print version information and exit.
209

EXAMPLES

211       This example converts a baseline JPEG file to progressive form:
212
213              jpegtran -progressive foo.jpg > fooprog.jpg
214
215       This example rotates an image  90  degrees  clockwise,  discarding  any
216       unrotatable edge pixels:
217
218              jpegtran -rot 90 -trim foo.jpg > foo90.jpg
219

ENVIRONMENT

221       JPEGMEM
222              If  this  environment  variable is set, its value is the default
223              memory limit.  The value  is  specified  as  described  for  the
224              -maxmemory  switch.   JPEGMEM overrides the default value speci‐
225              fied when the program was compiled, and itself is overridden  by
226              an explicit -maxmemory.
227

SEE ALSO

229       cjpeg(1), djpeg(1), rdjpgcom(1), wrjpgcom(1)
230       Wallace,  Gregory  K.   "The  JPEG Still Picture Compression Standard",
231       Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44.
232

AUTHOR

234       Independent JPEG Group
235
236       This file was modified by The libjpeg-turbo  Project  to  include  only
237       information  relevant  to  libjpeg-turbo  and to wordsmith certain sec‐
238       tions.
239

BUGS

241       The transform options can't transform odd-size images  perfectly.   Use
242       -trim or -perfect if you don't like the results.
243
244       The  entire  image is read into memory and then written out again, even
245       in cases where this isn't really necessary.  Expect swapping  on  large
246       images, especially when using the more complex transform options.
247
248
249
250                                 18 March 2017                     JPEGTRAN(1)
Impressum