Blame | Last modification | View Log | RSS feed
.TH JPEGTRAN 1 "3 August 1997".SH NAMEjpegtran \- lossless transformation of JPEG files.SH SYNOPSIS.B jpegtran[.I options][.I filename].LP.SH DESCRIPTION.LP.B jpegtranperforms various useful transformations of JPEG files.It can translate the coded representation from one variant of JPEG to another,for example from baseline JPEG to progressive JPEG or vice versa. It can alsoperform some rearrangements of the image data, for example turning an imagefrom landscape to portrait format by rotation..PP.B jpegtranworks by rearranging the compressed data (DCT coefficients), withoutever fully decoding the image. Therefore, its transformations are lossless:there is no image degradation at all, which would not be true if you used.B djpegfollowed by.B cjpegto accomplish the same conversion. But by the same token,.B jpegtrancannot perform lossy operations such as changing the image quality..PP.B jpegtranreads the named JPEG/JFIF file, or the standard input if no file isnamed, and produces a JPEG/JFIF file on the standard output..SH OPTIONSAll switch names may be abbreviated; for example,.B \-optimizemay be written.B \-optor.BR \-o .Upper and lower case are equivalent.British spellings are also accepted (e.g.,.BR \-optimise ),though for brevity these are not mentioned below..PPTo specify the coded JPEG representation used in the output file,.B jpegtranaccepts a subset of the switches recognized by.BR cjpeg :.TP.B \-optimizePerform optimization of entropy encoding parameters..TP.B \-progressiveCreate progressive JPEG file..TP.BI \-restart " N"Emit a JPEG restart marker every N MCU rows, or every N MCU blocks if "B" isattached to the number..TP.BI \-scans " file"Use the scan script given in the specified text file..PPSee.BR cjpeg (1)for more details about these switches.If you specify none of these switches, you get a plain baseline-JPEG outputfile. The quality setting and so forth are determined by the input file..PPThe image can be losslessly transformed by giving one of these switches:.TP.B \-flip horizontalMirror image horizontally (left-right)..TP.B \-flip verticalMirror image vertically (top-bottom)..TP.B \-rotate 90Rotate image 90 degrees clockwise..TP.B \-rotate 180Rotate image 180 degrees..TP.B \-rotate 270Rotate image 270 degrees clockwise (or 90 ccw)..TP.B \-transposeTranspose image (across UL-to-LR axis)..TP.B \-transverseTransverse transpose (across UR-to-LL axis)..PPThe transpose transformation has no restrictions regarding image dimensions.The other transformations operate rather oddly if the image dimensions are nota multiple of the iMCU size (usually 8 or 16 pixels), because they can onlytransform complete blocks of DCT coefficient data in the desired way..PP.BR jpegtran 'sdefault behavior when transforming an odd-size image is designedto preserve exact reversibility and mathematical consistency of thetransformation set. As stated, transpose is able to flip the entire imagearea. Horizontal mirroring leaves any partial iMCU column at the right edgeuntouched, but is able to flip all rows of the image. Similarly, verticalmirroring leaves any partial iMCU row at the bottom edge untouched, but isable to flip all columns. The other transforms can be built up as sequencesof transpose and flip operations; for consistency, their actions on edgepixels are defined to be the same as the end result of the correspondingtranspose-and-flip sequence..PPFor practical use, you may prefer to discard any untransformable edge pixelsrather than having a strange-looking strip along the right and/or bottom edgesof a transformed image. To do this, add the.B \-trimswitch:.TP.B \-trimDrop non-transformable edge blocks..PPObviously, a transformation with.B \-trimis not reversible, so strictly speaking.B jpegtranwith this switch is not lossless. Also, the expected mathematicalequivalences between the transformations no longer hold. For example,.B \-rot 270 -trimtrims only the bottom edge, but.B \-rot 90 -trimfollowed by.B \-rot 180 -trimtrims both edges..PPAnother not-strictly-lossless transformation switch is:.TP.B \-grayscaleForce grayscale output..PPThis option discards the chrominance channels if the input image is YCbCr(ie, a standard color JPEG), resulting in a grayscale JPEG file. Theluminance channel is preserved exactly, so this is a better method of reducingto grayscale than decompression, conversion, and recompression. This switchis particularly handy for fixing a monochrome picture that was mistakenlyencoded as a color JPEG. (In such a case, the space savings from getting ridof the near-empty chroma channels won't be large; but the decoding time fora grayscale JPEG is substantially less than that for a color JPEG.).PP.B jpegtranalso recognizes these switches that control what to do with "extra" markers,such as comment blocks:.TP.B \-copy noneCopy no extra markers from source file. This setting suppresses allcomments and other excess baggage present in the source file..TP.B \-copy commentsCopy only comment markers. This setting copies comments from the source file,but discards any other inessential data..TP.B \-copy allCopy all extra markers. This setting preserves miscellaneous markersfound in the source file, such as JFIF thumbnails and Photoshop settings.In some files these extra markers can be sizable..PPThe default behavior is.BR "\-copy comments" .(Note: in IJG releases v6 and v6a,.B jpegtranalways did the equivalent of.BR "\-copy none" .).PPAdditional switches recognized by jpegtran are:.TP.BI \-maxmemory " N"Set limit for amount of memory to use in processing large images. Value isin thousands of bytes, or millions of bytes if "M" is attached to thenumber. For example,.B \-max 4mselects 4000000 bytes. If more space is needed, temporary files will be used..TP.BI \-outfile " name"Send output image to the named file, not to standard output..TP.B \-verboseEnable debug printout. More.BR \-v 'sgive more output. Also, version information is printed at startup..TP.B \-debugSame as.BR \-verbose ..SH EXAMPLES.LPThis example converts a baseline JPEG file to progressive form:.IP.B jpegtran \-progressive.I foo.jpg.B >.I fooprog.jpg.PPThis example rotates an image 90 degrees clockwise, discarding anyunrotatable edge pixels:.IP.B jpegtran \-rot 90 -trim.I foo.jpg.B >.I foo90.jpg.SH ENVIRONMENT.TP.B JPEGMEMIf this environment variable is set, its value is the default memory limit.The value is specified as described for the.B \-maxmemoryswitch..B JPEGMEMoverrides the default value specified when the program was compiled, anditself is overridden by an explicit.BR \-maxmemory ..SH SEE ALSO.BR cjpeg (1),.BR djpeg (1),.BR rdjpgcom (1),.BR wrjpgcom (1).brWallace, Gregory K. "The JPEG Still Picture Compression Standard",Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44..SH AUTHORIndependent JPEG Group.SH BUGSArithmetic coding is not supported for legal reasons..PPThe transform options can't transform odd-size images perfectly. Use.B \-trimif you don't like the results without it..PPThe entire image is read into memory and then written out again, even incases where this isn't really necessary. Expect swapping on large images,especially when using the more complex transform options.