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