JPEGTRAN(1) JPEGTRAN(1) NAME jpegtran−losslesstransformationofJPEGfiles SYNOPSIS jpegtran[options][filename] DESCRIPTION jpegtranperformsvarioususefultransformationsofJPEGfiles.ItcantranslatethecodedrepresentationfromonevariantofJPEGtoanother,forexamplefrombaselineJPEGtoprogressive JPEGorviceversa.Itcanalsoperformsomerearrangementsoftheimagedata,forexample turninganimagefromlandscapetoportraitformatbyrotation. jpegtranworksbyrearrangingthecompresseddata(DCTcoefficients),withouteverfullydecodingtheimage.Therefore,itstransformationsarelossless:thereisnoimagedegradationatall, whichwouldnotbetrueifyouuseddjpegfollowedbycjpegtoaccomplishthesameconversion. Butbythesametoken,jpegtrancannotperformlossyoperationssuchaschangingtheimage quality. jpegtranreadsthenamedJPEG/JFIFfile,orthestandardinputifnofileisnamed,andproducesaJPEG/JFIFfileonthestandardoutput. OPTIONS Allswitchnamesmaybeabbreviated;forexample,−optimizemaybewritten−optor−o. Upperandlowercaseareequivalent.Britishspellingsarealsoaccepted(e.g.,−optimise), thoughforbrevitythesearenotmentionedbelow. TospecifythecodedJPEGrepresentationusedintheoutputfile,jpegtranacceptsasubsetof theswitchesrecognizedbycjpeg: −optimize Performoptimizationofentropyencodingparameters. −progressive CreateprogressiveJPEGfile. −restartN EmitaJPEGrestartmarkereveryNMCUrows,oreveryNMCUblocksif"B"is attachedtothenumber. −scansfile Usethescanscriptgiveninthespecifiedtextfile. Seecjpeg(1)formoredetailsabouttheseswitches.Ifyouspecifynoneoftheseswitches,youget aplainbaseline-JPEGoutputfile.Thequalitysettingandsofortharedeterminedbytheinput file. Theimagecanbelosslesslytransformedbygivingoneoftheseswitches: −fliphorizontal Mirrorimagehorizontally(left-right). −flipvertical Mirrorimagevertically(top-bottom). −rotate90 Rotateimage90degreesclockwise. −rotate180 Rotateimage180degrees. −rotate270 Rotateimage270degreesclockwise(or90ccw). 3August1997 1 JPEGTRAN(1) JPEGTRAN(1) −transpose Transposeimage(acrossUL-to-LRaxis). −transverse Transversetranspose(acrossUR-to-LLaxis). Thetransposetransformationhasnorestrictionsregardingimagedimensions.TheothertransformationsoperateratheroddlyiftheimagedimensionsarenotamultipleoftheiMCUsize(usually 8or16pixels),becausetheycanonlytransformcompleteblocksofDCTcoefficientdatainthe desiredway. jpegtran’sdefaultbehaviorwhentransforminganodd-sizeimageisdesignedtopreserveexact reversibilityandmathematicalconsistencyofthetransformationset.Asstated,transposeisable tofliptheentireimagearea.HorizontalmirroringleavesanypartialiMCUcolumnattheright edgeuntouched,butisabletoflipallrowsoftheimage.Similarly,verticalmirroringleavesany partialiMCUrowatthebottomedgeuntouched,butisabletoflipallcolumns.Theothertransformscanbebuiltupassequencesoftransposeandflipoperations;forconsistency,theiractions onedgepixelsaredefinedtobethesameastheendresultofthecorrespondingtranspose-and-flip sequence. Forpracticaluse,youmayprefertodiscardanyuntransformableedgepixelsratherthanhavinga strange-lookingstripalongtherightand/orbottomedgesofatransformedimage.Todothis, addthe−trimswitch: −trimDropnon-transformableedgeblocks. Obviously,atransformationwith−trimisnotreversible,sostrictlyspeakingjpegtranwiththis switchisnotlossless.Also,theexpectedmathematicalequivalencesbetweenthetransformations nolongerhold.Forexample,−rot270-trimtrimsonlythebottomedge,but−rot90-trim followedby−rot180-trimtrimsbothedges. Anothernot-strictly-losslesstransformationswitchis: −grayscale Forcegrayscaleoutput. ThisoptiondiscardsthechrominancechannelsiftheinputimageisYCbCr(ie,astandardcolor JPEG),resultinginagrayscaleJPEGfile.Theluminancechannelispreservedexactly,sothisis abettermethodofreducingtograyscalethandecompression,conversion,andrecompression. Thisswitchisparticularlyhandyforfixingamonochromepicturethatwasmistakenlyencodedas acolorJPEG.(Insuchacase,thespacesavingsfromgettingridofthenear-emptychromachan-nelswon’tbelarge;butthedecodingtimeforagrayscaleJPEGissubstantiallylessthanthatfor acolorJPEG.) jpegtranalsorecognizestheseswitchesthatcontrolwhattodowith"extra"markers,suchas commentblocks: −copynone Copynoextramarkersfromsourcefile.Thissettingsuppressesallcommentsandother excessbaggagepresentinthesourcefile. −copycomments Copyonlycommentmarkers.Thissettingcopiescommentsfromthesourcefile,butdiscardsanyotherinessentialdata. −copyall Copyallextramarkers.Thissettingpreservesmiscellaneousmarkersfoundinthesource file,suchasJFIFthumbnailsandPhotoshopsettings.Insomefilestheseextramarkers canbesizable. Thedefaultbehavioris−copycomments.(Note:inIJGreleasesv6andv6a,jpegtranalways didtheequivalentof−copynone.) Additionalswitchesrecognizedbyjpegtranare: 3August1997 2 JPEGTRAN(1) JPEGTRAN(1) −maxmemoryN Setlimitforamountofmemorytouseinprocessinglargeimages.Valueisinthousands ofbytes,ormillionsofbytesif"M"isattachedtothenumber.Forexample,−max4m selects4000000bytes.Ifmorespaceisneeded,temporaryfileswillbeused. −outfilename Sendoutputimagetothenamedfile,nottostandardoutput. −verbose Enabledebugprintout.More−v’sgivemoreoutput.Also,versioninformationisprinted atstartup. −debug Sameas−verbose. EXAMPLES ThisexampleconvertsabaselineJPEGfiletoprogressiveform: jpegtran−progressivefoo.jpg>fooprog.jpg Thisexamplerotatesanimage90degreesclockwise,discardinganyunrotatableedgepixels: jpegtran−rot90-trimfoo.jpg>foo90.jpg ENVIRONMENT JPEGMEM Ifthisenvironmentvariableisset,itsvalueisthedefaultmemorylimit.Thevalueis specifiedasdescribedforthe−maxmemoryswitch.JPEGMEMoverridesthedefault valuespecifiedwhentheprogramwascompiled,anditselfisoverriddenbyanexplicit −maxmemory. SEEALSO cjpeg(1),djpeg(1),rdjpgcom(1),wrjpgcom(1) Wallace,GregoryK."TheJPEGStillPictureCompressionStandard",Communicationsofthe ACM,April1991(vol.34,no.4),pp.30-44. AUTHOR IndependentJPEGGroup BUGS Arithmeticcodingisnotsupportedforlegalreasons. Thetransformoptionscan’ttransformodd-sizeimagesperfectly.Use−trimifyoudon’tlikethe resultswithoutit. Theentireimageisreadintomemoryandthenwrittenoutagain,evenincaseswherethisisn’t reallynecessary.Expectswappingonlargeimages,especiallywhenusingthemorecomplextransformoptions. 3August1997 3