1*dfc6aa5cSAndroid Build Coastguard WorkerNOTE: This file was modified by The libjpeg-turbo Project to include only 2*dfc6aa5cSAndroid Build Coastguard Workerinformation relevant to libjpeg-turbo and to wordsmith certain sections. 3*dfc6aa5cSAndroid Build Coastguard Worker 4*dfc6aa5cSAndroid Build Coastguard WorkerUSAGE instructions for the Independent JPEG Group's JPEG software 5*dfc6aa5cSAndroid Build Coastguard Worker================================================================= 6*dfc6aa5cSAndroid Build Coastguard Worker 7*dfc6aa5cSAndroid Build Coastguard WorkerThis file describes usage of the JPEG conversion programs cjpeg and djpeg, 8*dfc6aa5cSAndroid Build Coastguard Workeras well as the utility programs jpegtran, rdjpgcom and wrjpgcom. (See 9*dfc6aa5cSAndroid Build Coastguard Workerthe other documentation files if you wish to use the JPEG library within 10*dfc6aa5cSAndroid Build Coastguard Workeryour own programs.) 11*dfc6aa5cSAndroid Build Coastguard Worker 12*dfc6aa5cSAndroid Build Coastguard WorkerIf you are on a Unix machine you may prefer to read the Unix-style manual 13*dfc6aa5cSAndroid Build Coastguard Workerpages in files cjpeg.1, djpeg.1, jpegtran.1, rdjpgcom.1, wrjpgcom.1. 14*dfc6aa5cSAndroid Build Coastguard Worker 15*dfc6aa5cSAndroid Build Coastguard Worker 16*dfc6aa5cSAndroid Build Coastguard WorkerINTRODUCTION 17*dfc6aa5cSAndroid Build Coastguard Worker 18*dfc6aa5cSAndroid Build Coastguard WorkerThese programs implement JPEG image encoding, decoding, and transcoding. 19*dfc6aa5cSAndroid Build Coastguard WorkerJPEG (pronounced "jay-peg") is a standardized compression method for 20*dfc6aa5cSAndroid Build Coastguard Workerfull-color and grayscale images. 21*dfc6aa5cSAndroid Build Coastguard Worker 22*dfc6aa5cSAndroid Build Coastguard Worker 23*dfc6aa5cSAndroid Build Coastguard WorkerGENERAL USAGE 24*dfc6aa5cSAndroid Build Coastguard Worker 25*dfc6aa5cSAndroid Build Coastguard WorkerWe provide two programs, cjpeg to compress an image file into JPEG format, 26*dfc6aa5cSAndroid Build Coastguard Workerand djpeg to decompress a JPEG file back into a conventional image format. 27*dfc6aa5cSAndroid Build Coastguard Worker 28*dfc6aa5cSAndroid Build Coastguard WorkerOn most systems, you say: 29*dfc6aa5cSAndroid Build Coastguard Worker cjpeg [switches] [imagefile] >jpegfile 30*dfc6aa5cSAndroid Build Coastguard Workeror 31*dfc6aa5cSAndroid Build Coastguard Worker djpeg [switches] [jpegfile] >imagefile 32*dfc6aa5cSAndroid Build Coastguard WorkerThe programs read the specified input file, or standard input if none is 33*dfc6aa5cSAndroid Build Coastguard Workernamed. They always write to standard output (with trace/error messages to 34*dfc6aa5cSAndroid Build Coastguard Workerstandard error). These conventions are handy for piping images between 35*dfc6aa5cSAndroid Build Coastguard Workerprograms. 36*dfc6aa5cSAndroid Build Coastguard Worker 37*dfc6aa5cSAndroid Build Coastguard WorkerIf you defined TWO_FILE_COMMANDLINE when compiling the programs, you can 38*dfc6aa5cSAndroid Build Coastguard Workerinstead say: 39*dfc6aa5cSAndroid Build Coastguard Worker cjpeg [switches] imagefile jpegfile 40*dfc6aa5cSAndroid Build Coastguard Workeror 41*dfc6aa5cSAndroid Build Coastguard Worker djpeg [switches] jpegfile imagefile 42*dfc6aa5cSAndroid Build Coastguard Workeri.e., both the input and output files are named on the command line. This 43*dfc6aa5cSAndroid Build Coastguard Workerstyle is a little more foolproof, and it loses no functionality if you don't 44*dfc6aa5cSAndroid Build Coastguard Workerhave pipes. 45*dfc6aa5cSAndroid Build Coastguard Worker 46*dfc6aa5cSAndroid Build Coastguard WorkerYou can also say: 47*dfc6aa5cSAndroid Build Coastguard Worker cjpeg [switches] -outfile jpegfile imagefile 48*dfc6aa5cSAndroid Build Coastguard Workeror 49*dfc6aa5cSAndroid Build Coastguard Worker djpeg [switches] -outfile imagefile jpegfile 50*dfc6aa5cSAndroid Build Coastguard WorkerThis syntax works on all systems, so it is useful for scripts. 51*dfc6aa5cSAndroid Build Coastguard Worker 52*dfc6aa5cSAndroid Build Coastguard WorkerThe currently supported image file formats are: PPM (PBMPLUS color format), 53*dfc6aa5cSAndroid Build Coastguard WorkerPGM (PBMPLUS grayscale format), BMP, GIF, and Targa. cjpeg recognizes the 54*dfc6aa5cSAndroid Build Coastguard Workerinput image format automatically, with the exception of some Targa files. You 55*dfc6aa5cSAndroid Build Coastguard Workerhave to tell djpeg which format to generate. 56*dfc6aa5cSAndroid Build Coastguard Worker 57*dfc6aa5cSAndroid Build Coastguard WorkerJPEG files are in the defacto standard JFIF file format. There are other, 58*dfc6aa5cSAndroid Build Coastguard Workerless widely used JPEG-based file formats, but we don't support them. 59*dfc6aa5cSAndroid Build Coastguard Worker 60*dfc6aa5cSAndroid Build Coastguard WorkerAll switch names may be abbreviated; for example, -grayscale may be written 61*dfc6aa5cSAndroid Build Coastguard Worker-gray or -gr. Most of the "basic" switches can be abbreviated to as little as 62*dfc6aa5cSAndroid Build Coastguard Workerone letter. Upper and lower case are equivalent (-BMP is the same as -bmp). 63*dfc6aa5cSAndroid Build Coastguard WorkerBritish spellings are also accepted (e.g., -greyscale), though for brevity 64*dfc6aa5cSAndroid Build Coastguard Workerthese are not mentioned below. 65*dfc6aa5cSAndroid Build Coastguard Worker 66*dfc6aa5cSAndroid Build Coastguard Worker 67*dfc6aa5cSAndroid Build Coastguard WorkerCJPEG DETAILS 68*dfc6aa5cSAndroid Build Coastguard Worker 69*dfc6aa5cSAndroid Build Coastguard WorkerThe basic command line switches for cjpeg are: 70*dfc6aa5cSAndroid Build Coastguard Worker 71*dfc6aa5cSAndroid Build Coastguard Worker -quality N[,...] Scale quantization tables to adjust image quality. 72*dfc6aa5cSAndroid Build Coastguard Worker Quality is 0 (worst) to 100 (best); default is 75. 73*dfc6aa5cSAndroid Build Coastguard Worker (See below for more info.) 74*dfc6aa5cSAndroid Build Coastguard Worker 75*dfc6aa5cSAndroid Build Coastguard Worker -grayscale Create monochrome JPEG file from color input. By 76*dfc6aa5cSAndroid Build Coastguard Worker saying -grayscale, you'll get a smaller JPEG file that 77*dfc6aa5cSAndroid Build Coastguard Worker takes less time to process. 78*dfc6aa5cSAndroid Build Coastguard Worker 79*dfc6aa5cSAndroid Build Coastguard Worker -rgb Create RGB JPEG file. 80*dfc6aa5cSAndroid Build Coastguard Worker Using this switch suppresses the conversion from RGB 81*dfc6aa5cSAndroid Build Coastguard Worker colorspace input to the default YCbCr JPEG colorspace. 82*dfc6aa5cSAndroid Build Coastguard Worker 83*dfc6aa5cSAndroid Build Coastguard Worker -optimize Perform optimization of entropy encoding parameters. 84*dfc6aa5cSAndroid Build Coastguard Worker Without this, default encoding parameters are used. 85*dfc6aa5cSAndroid Build Coastguard Worker -optimize usually makes the JPEG file a little smaller, 86*dfc6aa5cSAndroid Build Coastguard Worker but cjpeg runs somewhat slower and needs much more 87*dfc6aa5cSAndroid Build Coastguard Worker memory. Image quality and speed of decompression are 88*dfc6aa5cSAndroid Build Coastguard Worker unaffected by -optimize. 89*dfc6aa5cSAndroid Build Coastguard Worker 90*dfc6aa5cSAndroid Build Coastguard Worker -progressive Create progressive JPEG file (see below). 91*dfc6aa5cSAndroid Build Coastguard Worker 92*dfc6aa5cSAndroid Build Coastguard Worker -targa Input file is Targa format. Targa files that contain 93*dfc6aa5cSAndroid Build Coastguard Worker an "identification" field will not be automatically 94*dfc6aa5cSAndroid Build Coastguard Worker recognized by cjpeg; for such files you must specify 95*dfc6aa5cSAndroid Build Coastguard Worker -targa to make cjpeg treat the input as Targa format. 96*dfc6aa5cSAndroid Build Coastguard Worker For most Targa files, you won't need this switch. 97*dfc6aa5cSAndroid Build Coastguard Worker 98*dfc6aa5cSAndroid Build Coastguard WorkerThe -quality switch lets you trade off compressed file size against quality of 99*dfc6aa5cSAndroid Build Coastguard Workerthe reconstructed image: the higher the quality setting, the larger the JPEG 100*dfc6aa5cSAndroid Build Coastguard Workerfile, and the closer the output image will be to the original input. Normally 101*dfc6aa5cSAndroid Build Coastguard Workeryou want to use the lowest quality setting (smallest file) that decompresses 102*dfc6aa5cSAndroid Build Coastguard Workerinto something visually indistinguishable from the original image. For this 103*dfc6aa5cSAndroid Build Coastguard Workerpurpose the quality setting should generally be between 50 and 95 (the default 104*dfc6aa5cSAndroid Build Coastguard Workeris 75) for photographic images. If you see defects at -quality 75, then go up 105*dfc6aa5cSAndroid Build Coastguard Worker5 or 10 counts at a time until you are happy with the output image. (The 106*dfc6aa5cSAndroid Build Coastguard Workeroptimal setting will vary from one image to another.) 107*dfc6aa5cSAndroid Build Coastguard Worker 108*dfc6aa5cSAndroid Build Coastguard Worker-quality 100 will generate a quantization table of all 1's, minimizing loss 109*dfc6aa5cSAndroid Build Coastguard Workerin the quantization step (but there is still information loss in subsampling, 110*dfc6aa5cSAndroid Build Coastguard Workeras well as roundoff error.) For most images, specifying a quality value above 111*dfc6aa5cSAndroid Build Coastguard Workerabout 95 will increase the size of the compressed file dramatically, and while 112*dfc6aa5cSAndroid Build Coastguard Workerthe quality gain from these higher quality values is measurable (using metrics 113*dfc6aa5cSAndroid Build Coastguard Workersuch as PSNR or SSIM), it is rarely perceivable by human vision. 114*dfc6aa5cSAndroid Build Coastguard Worker 115*dfc6aa5cSAndroid Build Coastguard WorkerIn the other direction, quality values below 50 will produce very small files 116*dfc6aa5cSAndroid Build Coastguard Workerof low image quality. Settings around 5 to 10 might be useful in preparing an 117*dfc6aa5cSAndroid Build Coastguard Workerindex of a large image library, for example. Try -quality 2 (or so) for some 118*dfc6aa5cSAndroid Build Coastguard Workeramusing Cubist effects. (Note: quality values below about 25 generate 2-byte 119*dfc6aa5cSAndroid Build Coastguard Workerquantization tables, which are considered optional in the JPEG standard. 120*dfc6aa5cSAndroid Build Coastguard Workercjpeg emits a warning message when you give such a quality value, because some 121*dfc6aa5cSAndroid Build Coastguard Workerother JPEG programs may be unable to decode the resulting file. Use -baseline 122*dfc6aa5cSAndroid Build Coastguard Workerif you need to ensure compatibility at low quality values.) 123*dfc6aa5cSAndroid Build Coastguard Worker 124*dfc6aa5cSAndroid Build Coastguard WorkerThe -quality option has been extended in this version of cjpeg to support 125*dfc6aa5cSAndroid Build Coastguard Workerseparate quality settings for luminance and chrominance (or, in general, 126*dfc6aa5cSAndroid Build Coastguard Workerseparate settings for every quantization table slot.) The principle is the 127*dfc6aa5cSAndroid Build Coastguard Workersame as chrominance subsampling: since the human eye is more sensitive to 128*dfc6aa5cSAndroid Build Coastguard Workerspatial changes in brightness than spatial changes in color, the chrominance 129*dfc6aa5cSAndroid Build Coastguard Workercomponents can be quantized more than the luminance components without 130*dfc6aa5cSAndroid Build Coastguard Workerincurring any visible image quality loss. However, unlike subsampling, this 131*dfc6aa5cSAndroid Build Coastguard Workerfeature reduces data in the frequency domain instead of the spatial domain, 132*dfc6aa5cSAndroid Build Coastguard Workerwhich allows for more fine-grained control. This option is useful in 133*dfc6aa5cSAndroid Build Coastguard Workerquality-sensitive applications, for which the artifacts generated by 134*dfc6aa5cSAndroid Build Coastguard Workersubsampling may be unacceptable. 135*dfc6aa5cSAndroid Build Coastguard Worker 136*dfc6aa5cSAndroid Build Coastguard WorkerThe -quality option accepts a comma-separated list of parameters, which 137*dfc6aa5cSAndroid Build Coastguard Workerrespectively refer to the quality levels that should be assigned to the 138*dfc6aa5cSAndroid Build Coastguard Workerquantization table slots. If there are more q-table slots than parameters, 139*dfc6aa5cSAndroid Build Coastguard Workerthen the last parameter is replicated. Thus, if only one quality parameter is 140*dfc6aa5cSAndroid Build Coastguard Workergiven, this is used for both luminance and chrominance (slots 0 and 1, 141*dfc6aa5cSAndroid Build Coastguard Workerrespectively), preserving the legacy behavior of cjpeg v6b and prior. More (or 142*dfc6aa5cSAndroid Build Coastguard Workercustomized) quantization tables can be set with the -qtables option and 143*dfc6aa5cSAndroid Build Coastguard Workerassigned to components with the -qslots option (see the "wizard" switches 144*dfc6aa5cSAndroid Build Coastguard Workerbelow.) 145*dfc6aa5cSAndroid Build Coastguard Worker 146*dfc6aa5cSAndroid Build Coastguard WorkerJPEG files generated with separate luminance and chrominance quality are fully 147*dfc6aa5cSAndroid Build Coastguard Workercompliant with standard JPEG decoders. 148*dfc6aa5cSAndroid Build Coastguard Worker 149*dfc6aa5cSAndroid Build Coastguard WorkerCAUTION: For this setting to be useful, be sure to pass an argument of 150*dfc6aa5cSAndroid Build Coastguard Worker-sample 1x1 to cjpeg to disable chrominance subsampling. Otherwise, the 151*dfc6aa5cSAndroid Build Coastguard Workerdefault subsampling level (2x2, AKA "4:2:0") will be used. 152*dfc6aa5cSAndroid Build Coastguard Worker 153*dfc6aa5cSAndroid Build Coastguard WorkerThe -progressive switch creates a "progressive JPEG" file. In this type of 154*dfc6aa5cSAndroid Build Coastguard WorkerJPEG file, the data is stored in multiple scans of increasing quality. If the 155*dfc6aa5cSAndroid Build Coastguard Workerfile is being transmitted over a slow communications link, the decoder can use 156*dfc6aa5cSAndroid Build Coastguard Workerthe first scan to display a low-quality image very quickly, and can then 157*dfc6aa5cSAndroid Build Coastguard Workerimprove the display with each subsequent scan. The final image is exactly 158*dfc6aa5cSAndroid Build Coastguard Workerequivalent to a standard JPEG file of the same quality setting, and the total 159*dfc6aa5cSAndroid Build Coastguard Workerfile size is about the same --- often a little smaller. 160*dfc6aa5cSAndroid Build Coastguard Worker 161*dfc6aa5cSAndroid Build Coastguard WorkerSwitches for advanced users: 162*dfc6aa5cSAndroid Build Coastguard Worker 163*dfc6aa5cSAndroid Build Coastguard Worker -arithmetic Use arithmetic coding. CAUTION: arithmetic coded JPEG 164*dfc6aa5cSAndroid Build Coastguard Worker is not yet widely implemented, so many decoders will 165*dfc6aa5cSAndroid Build Coastguard Worker be unable to view an arithmetic coded JPEG file at 166*dfc6aa5cSAndroid Build Coastguard Worker all. 167*dfc6aa5cSAndroid Build Coastguard Worker 168*dfc6aa5cSAndroid Build Coastguard Worker -dct int Use accurate integer DCT method (default). 169*dfc6aa5cSAndroid Build Coastguard Worker -dct fast Use less accurate integer DCT method [legacy feature]. 170*dfc6aa5cSAndroid Build Coastguard Worker When the Independent JPEG Group's software was first 171*dfc6aa5cSAndroid Build Coastguard Worker released in 1991, the compression time for a 172*dfc6aa5cSAndroid Build Coastguard Worker 1-megapixel JPEG image on a mainstream PC was measured 173*dfc6aa5cSAndroid Build Coastguard Worker in minutes. Thus, the fast integer DCT algorithm 174*dfc6aa5cSAndroid Build Coastguard Worker provided noticeable performance benefits. On modern 175*dfc6aa5cSAndroid Build Coastguard Worker CPUs running libjpeg-turbo, however, the compression 176*dfc6aa5cSAndroid Build Coastguard Worker time for a 1-megapixel JPEG image is measured in 177*dfc6aa5cSAndroid Build Coastguard Worker milliseconds, and thus the performance benefits of the 178*dfc6aa5cSAndroid Build Coastguard Worker fast algorithm are much less noticeable. On modern 179*dfc6aa5cSAndroid Build Coastguard Worker x86/x86-64 CPUs that support AVX2 instructions, the 180*dfc6aa5cSAndroid Build Coastguard Worker fast and int methods have similar performance. On 181*dfc6aa5cSAndroid Build Coastguard Worker other types of CPUs, the fast method is generally about 182*dfc6aa5cSAndroid Build Coastguard Worker 5-15% faster than the int method. 183*dfc6aa5cSAndroid Build Coastguard Worker 184*dfc6aa5cSAndroid Build Coastguard Worker For quality levels of 90 and below, there should be 185*dfc6aa5cSAndroid Build Coastguard Worker little or no perceptible quality difference between the 186*dfc6aa5cSAndroid Build Coastguard Worker two algorithms. For quality levels above 90, however, 187*dfc6aa5cSAndroid Build Coastguard Worker the difference between the fast and int methods becomes 188*dfc6aa5cSAndroid Build Coastguard Worker more pronounced. With quality=97, for instance, the 189*dfc6aa5cSAndroid Build Coastguard Worker fast method incurs generally about a 1-3 dB loss in 190*dfc6aa5cSAndroid Build Coastguard Worker PSNR relative to the int method, but this can be larger 191*dfc6aa5cSAndroid Build Coastguard Worker for some images. Do not use the fast method with 192*dfc6aa5cSAndroid Build Coastguard Worker quality levels above 97. The algorithm often 193*dfc6aa5cSAndroid Build Coastguard Worker degenerates at quality=98 and above and can actually 194*dfc6aa5cSAndroid Build Coastguard Worker produce a more lossy image than if lower quality levels 195*dfc6aa5cSAndroid Build Coastguard Worker had been used. Also, in libjpeg-turbo, the fast method 196*dfc6aa5cSAndroid Build Coastguard Worker is not fully accelerated for quality levels above 97, 197*dfc6aa5cSAndroid Build Coastguard Worker so it will be slower than the int method. 198*dfc6aa5cSAndroid Build Coastguard Worker -dct float Use floating-point DCT method [legacy feature]. 199*dfc6aa5cSAndroid Build Coastguard Worker The float method does not produce significantly more 200*dfc6aa5cSAndroid Build Coastguard Worker accurate results than the int method, and it is much 201*dfc6aa5cSAndroid Build Coastguard Worker slower. The float method may also give different 202*dfc6aa5cSAndroid Build Coastguard Worker results on different machines due to varying roundoff 203*dfc6aa5cSAndroid Build Coastguard Worker behavior, whereas the integer methods should give the 204*dfc6aa5cSAndroid Build Coastguard Worker same results on all machines. 205*dfc6aa5cSAndroid Build Coastguard Worker 206*dfc6aa5cSAndroid Build Coastguard Worker -restart N Emit a JPEG restart marker every N MCU rows, or every 207*dfc6aa5cSAndroid Build Coastguard Worker N MCU blocks if "B" is attached to the number. 208*dfc6aa5cSAndroid Build Coastguard Worker -restart 0 (the default) means no restart markers. 209*dfc6aa5cSAndroid Build Coastguard Worker 210*dfc6aa5cSAndroid Build Coastguard Worker -smooth N Smooth the input image to eliminate dithering noise. 211*dfc6aa5cSAndroid Build Coastguard Worker N, ranging from 1 to 100, indicates the strength of 212*dfc6aa5cSAndroid Build Coastguard Worker smoothing. 0 (the default) means no smoothing. 213*dfc6aa5cSAndroid Build Coastguard Worker 214*dfc6aa5cSAndroid Build Coastguard Worker -maxmemory N Set limit for amount of memory to use in processing 215*dfc6aa5cSAndroid Build Coastguard Worker large images. Value is in thousands of bytes, or 216*dfc6aa5cSAndroid Build Coastguard Worker millions of bytes if "M" is attached to the number. 217*dfc6aa5cSAndroid Build Coastguard Worker For example, -max 4m selects 4000000 bytes. If more 218*dfc6aa5cSAndroid Build Coastguard Worker space is needed, an error will occur. 219*dfc6aa5cSAndroid Build Coastguard Worker 220*dfc6aa5cSAndroid Build Coastguard Worker -verbose Enable debug printout. More -v's give more printout. 221*dfc6aa5cSAndroid Build Coastguard Worker or -debug Also, version information is printed at startup. 222*dfc6aa5cSAndroid Build Coastguard Worker 223*dfc6aa5cSAndroid Build Coastguard WorkerThe -restart option inserts extra markers that allow a JPEG decoder to 224*dfc6aa5cSAndroid Build Coastguard Workerresynchronize after a transmission error. Without restart markers, any damage 225*dfc6aa5cSAndroid Build Coastguard Workerto a compressed file will usually ruin the image from the point of the error 226*dfc6aa5cSAndroid Build Coastguard Workerto the end of the image; with restart markers, the damage is usually confined 227*dfc6aa5cSAndroid Build Coastguard Workerto the portion of the image up to the next restart marker. Of course, the 228*dfc6aa5cSAndroid Build Coastguard Workerrestart markers occupy extra space. We recommend -restart 1 for images that 229*dfc6aa5cSAndroid Build Coastguard Workerwill be transmitted across unreliable networks such as Usenet. 230*dfc6aa5cSAndroid Build Coastguard Worker 231*dfc6aa5cSAndroid Build Coastguard WorkerThe -smooth option filters the input to eliminate fine-scale noise. This is 232*dfc6aa5cSAndroid Build Coastguard Workeroften useful when converting dithered images to JPEG: a moderate smoothing 233*dfc6aa5cSAndroid Build Coastguard Workerfactor of 10 to 50 gets rid of dithering patterns in the input file, resulting 234*dfc6aa5cSAndroid Build Coastguard Workerin a smaller JPEG file and a better-looking image. Too large a smoothing 235*dfc6aa5cSAndroid Build Coastguard Workerfactor will visibly blur the image, however. 236*dfc6aa5cSAndroid Build Coastguard Worker 237*dfc6aa5cSAndroid Build Coastguard WorkerSwitches for wizards: 238*dfc6aa5cSAndroid Build Coastguard Worker 239*dfc6aa5cSAndroid Build Coastguard Worker -baseline Force baseline-compatible quantization tables to be 240*dfc6aa5cSAndroid Build Coastguard Worker generated. This clamps quantization values to 8 bits 241*dfc6aa5cSAndroid Build Coastguard Worker even at low quality settings. (This switch is poorly 242*dfc6aa5cSAndroid Build Coastguard Worker named, since it does not ensure that the output is 243*dfc6aa5cSAndroid Build Coastguard Worker actually baseline JPEG. For example, you can use 244*dfc6aa5cSAndroid Build Coastguard Worker -baseline and -progressive together.) 245*dfc6aa5cSAndroid Build Coastguard Worker 246*dfc6aa5cSAndroid Build Coastguard Worker -qtables file Use the quantization tables given in the specified 247*dfc6aa5cSAndroid Build Coastguard Worker text file. 248*dfc6aa5cSAndroid Build Coastguard Worker 249*dfc6aa5cSAndroid Build Coastguard Worker -qslots N[,...] Select which quantization table to use for each color 250*dfc6aa5cSAndroid Build Coastguard Worker component. 251*dfc6aa5cSAndroid Build Coastguard Worker 252*dfc6aa5cSAndroid Build Coastguard Worker -sample HxV[,...] Set JPEG sampling factors for each color component. 253*dfc6aa5cSAndroid Build Coastguard Worker 254*dfc6aa5cSAndroid Build Coastguard Worker -scans file Use the scan script given in the specified text file. 255*dfc6aa5cSAndroid Build Coastguard Worker 256*dfc6aa5cSAndroid Build Coastguard WorkerThe "wizard" switches are intended for experimentation with JPEG. If you 257*dfc6aa5cSAndroid Build Coastguard Workerdon't know what you are doing, DON'T USE THEM. These switches are documented 258*dfc6aa5cSAndroid Build Coastguard Workerfurther in the file wizard.txt. 259*dfc6aa5cSAndroid Build Coastguard Worker 260*dfc6aa5cSAndroid Build Coastguard Worker 261*dfc6aa5cSAndroid Build Coastguard WorkerDJPEG DETAILS 262*dfc6aa5cSAndroid Build Coastguard Worker 263*dfc6aa5cSAndroid Build Coastguard WorkerThe basic command line switches for djpeg are: 264*dfc6aa5cSAndroid Build Coastguard Worker 265*dfc6aa5cSAndroid Build Coastguard Worker -colors N Reduce image to at most N colors. This reduces the 266*dfc6aa5cSAndroid Build Coastguard Worker or -quantize N number of colors used in the output image, so that it 267*dfc6aa5cSAndroid Build Coastguard Worker can be displayed on a colormapped display or stored in 268*dfc6aa5cSAndroid Build Coastguard Worker a colormapped file format. For example, if you have 269*dfc6aa5cSAndroid Build Coastguard Worker an 8-bit display, you'd need to reduce to 256 or fewer 270*dfc6aa5cSAndroid Build Coastguard Worker colors. (-colors is the recommended name, -quantize 271*dfc6aa5cSAndroid Build Coastguard Worker is provided only for backwards compatibility.) 272*dfc6aa5cSAndroid Build Coastguard Worker 273*dfc6aa5cSAndroid Build Coastguard Worker -fast Select recommended processing options for fast, low 274*dfc6aa5cSAndroid Build Coastguard Worker quality output. (The default options are chosen for 275*dfc6aa5cSAndroid Build Coastguard Worker highest quality output.) Currently, this is equivalent 276*dfc6aa5cSAndroid Build Coastguard Worker to "-dct fast -nosmooth -onepass -dither ordered". 277*dfc6aa5cSAndroid Build Coastguard Worker 278*dfc6aa5cSAndroid Build Coastguard Worker -grayscale Force grayscale output even if JPEG file is color. 279*dfc6aa5cSAndroid Build Coastguard Worker Useful for viewing on monochrome displays; also, 280*dfc6aa5cSAndroid Build Coastguard Worker djpeg runs noticeably faster in this mode. 281*dfc6aa5cSAndroid Build Coastguard Worker 282*dfc6aa5cSAndroid Build Coastguard Worker -rgb Force RGB output even if JPEG file is grayscale. 283*dfc6aa5cSAndroid Build Coastguard Worker 284*dfc6aa5cSAndroid Build Coastguard Worker -scale M/N Scale the output image by a factor M/N. Currently 285*dfc6aa5cSAndroid Build Coastguard Worker the scale factor must be M/8, where M is an integer 286*dfc6aa5cSAndroid Build Coastguard Worker between 1 and 16 inclusive, or any reduced fraction 287*dfc6aa5cSAndroid Build Coastguard Worker thereof (such as 1/2, 3/4, etc. Scaling is handy if 288*dfc6aa5cSAndroid Build Coastguard Worker the image is larger than your screen; also, djpeg runs 289*dfc6aa5cSAndroid Build Coastguard Worker much faster when scaling down the output. 290*dfc6aa5cSAndroid Build Coastguard Worker 291*dfc6aa5cSAndroid Build Coastguard Worker -bmp Select BMP output format (Windows flavor). 8-bit 292*dfc6aa5cSAndroid Build Coastguard Worker colormapped format is emitted if -colors or -grayscale 293*dfc6aa5cSAndroid Build Coastguard Worker is specified, or if the JPEG file is grayscale; 294*dfc6aa5cSAndroid Build Coastguard Worker otherwise, 24-bit full-color format is emitted. 295*dfc6aa5cSAndroid Build Coastguard Worker 296*dfc6aa5cSAndroid Build Coastguard Worker -gif Select GIF output format (LZW-compressed). Since GIF 297*dfc6aa5cSAndroid Build Coastguard Worker does not support more than 256 colors, -colors 256 is 298*dfc6aa5cSAndroid Build Coastguard Worker assumed (unless you specify a smaller number of 299*dfc6aa5cSAndroid Build Coastguard Worker colors). If you specify -fast, the default number of 300*dfc6aa5cSAndroid Build Coastguard Worker colors is 216. 301*dfc6aa5cSAndroid Build Coastguard Worker 302*dfc6aa5cSAndroid Build Coastguard Worker -gif0 Select GIF output format (uncompressed). Since GIF 303*dfc6aa5cSAndroid Build Coastguard Worker does not support more than 256 colors, -colors 256 is 304*dfc6aa5cSAndroid Build Coastguard Worker assumed (unless you specify a smaller number of 305*dfc6aa5cSAndroid Build Coastguard Worker colors). If you specify -fast, the default number of 306*dfc6aa5cSAndroid Build Coastguard Worker colors is 216. 307*dfc6aa5cSAndroid Build Coastguard Worker 308*dfc6aa5cSAndroid Build Coastguard Worker -os2 Select BMP output format (OS/2 1.x flavor). 8-bit 309*dfc6aa5cSAndroid Build Coastguard Worker colormapped format is emitted if -colors or -grayscale 310*dfc6aa5cSAndroid Build Coastguard Worker is specified, or if the JPEG file is grayscale; 311*dfc6aa5cSAndroid Build Coastguard Worker otherwise, 24-bit full-color format is emitted. 312*dfc6aa5cSAndroid Build Coastguard Worker 313*dfc6aa5cSAndroid Build Coastguard Worker -pnm Select PBMPLUS (PPM/PGM) output format (this is the 314*dfc6aa5cSAndroid Build Coastguard Worker default format). PGM is emitted if the JPEG file is 315*dfc6aa5cSAndroid Build Coastguard Worker grayscale or if -grayscale is specified; otherwise 316*dfc6aa5cSAndroid Build Coastguard Worker PPM is emitted. 317*dfc6aa5cSAndroid Build Coastguard Worker 318*dfc6aa5cSAndroid Build Coastguard Worker -targa Select Targa output format. Grayscale format is 319*dfc6aa5cSAndroid Build Coastguard Worker emitted if the JPEG file is grayscale or if 320*dfc6aa5cSAndroid Build Coastguard Worker -grayscale is specified; otherwise, colormapped format 321*dfc6aa5cSAndroid Build Coastguard Worker is emitted if -colors is specified; otherwise, 24-bit 322*dfc6aa5cSAndroid Build Coastguard Worker full-color format is emitted. 323*dfc6aa5cSAndroid Build Coastguard Worker 324*dfc6aa5cSAndroid Build Coastguard WorkerSwitches for advanced users: 325*dfc6aa5cSAndroid Build Coastguard Worker 326*dfc6aa5cSAndroid Build Coastguard Worker -dct int Use accurate integer DCT method (default). 327*dfc6aa5cSAndroid Build Coastguard Worker -dct fast Use less accurate integer DCT method [legacy feature]. 328*dfc6aa5cSAndroid Build Coastguard Worker When the Independent JPEG Group's software was first 329*dfc6aa5cSAndroid Build Coastguard Worker released in 1991, the decompression time for a 330*dfc6aa5cSAndroid Build Coastguard Worker 1-megapixel JPEG image on a mainstream PC was measured 331*dfc6aa5cSAndroid Build Coastguard Worker in minutes. Thus, the fast integer DCT algorithm 332*dfc6aa5cSAndroid Build Coastguard Worker provided noticeable performance benefits. On modern 333*dfc6aa5cSAndroid Build Coastguard Worker CPUs running libjpeg-turbo, however, the decompression 334*dfc6aa5cSAndroid Build Coastguard Worker time for a 1-megapixel JPEG image is measured in 335*dfc6aa5cSAndroid Build Coastguard Worker milliseconds, and thus the performance benefits of the 336*dfc6aa5cSAndroid Build Coastguard Worker fast algorithm are much less noticeable. On modern 337*dfc6aa5cSAndroid Build Coastguard Worker x86/x86-64 CPUs that support AVX2 instructions, the 338*dfc6aa5cSAndroid Build Coastguard Worker fast and int methods have similar performance. On 339*dfc6aa5cSAndroid Build Coastguard Worker other types of CPUs, the fast method is generally about 340*dfc6aa5cSAndroid Build Coastguard Worker 5-15% faster than the int method. 341*dfc6aa5cSAndroid Build Coastguard Worker 342*dfc6aa5cSAndroid Build Coastguard Worker If the JPEG image was compressed using a quality level 343*dfc6aa5cSAndroid Build Coastguard Worker of 85 or below, then there should be little or no 344*dfc6aa5cSAndroid Build Coastguard Worker perceptible quality difference between the two 345*dfc6aa5cSAndroid Build Coastguard Worker algorithms. When decompressing images that were 346*dfc6aa5cSAndroid Build Coastguard Worker compressed using quality levels above 85, however, the 347*dfc6aa5cSAndroid Build Coastguard Worker difference between the fast and int methods becomes 348*dfc6aa5cSAndroid Build Coastguard Worker more pronounced. With images compressed using 349*dfc6aa5cSAndroid Build Coastguard Worker quality=97, for instance, the fast method incurs 350*dfc6aa5cSAndroid Build Coastguard Worker generally about a 4-6 dB loss in PSNR relative to the 351*dfc6aa5cSAndroid Build Coastguard Worker int method, but this can be larger for some images. If 352*dfc6aa5cSAndroid Build Coastguard Worker you can avoid it, do not use the fast method when 353*dfc6aa5cSAndroid Build Coastguard Worker decompressing images that were compressed using quality 354*dfc6aa5cSAndroid Build Coastguard Worker levels above 97. The algorithm often degenerates for 355*dfc6aa5cSAndroid Build Coastguard Worker such images and can actually produce a more lossy 356*dfc6aa5cSAndroid Build Coastguard Worker output image than if the JPEG image had been compressed 357*dfc6aa5cSAndroid Build Coastguard Worker using lower quality levels. 358*dfc6aa5cSAndroid Build Coastguard Worker -dct float Use floating-point DCT method [legacy feature]. 359*dfc6aa5cSAndroid Build Coastguard Worker The float method does not produce significantly more 360*dfc6aa5cSAndroid Build Coastguard Worker accurate results than the int method, and it is much 361*dfc6aa5cSAndroid Build Coastguard Worker slower. The float method may also give different 362*dfc6aa5cSAndroid Build Coastguard Worker results on different machines due to varying roundoff 363*dfc6aa5cSAndroid Build Coastguard Worker behavior, whereas the integer methods should give the 364*dfc6aa5cSAndroid Build Coastguard Worker same results on all machines. 365*dfc6aa5cSAndroid Build Coastguard Worker 366*dfc6aa5cSAndroid Build Coastguard Worker -dither fs Use Floyd-Steinberg dithering in color quantization. 367*dfc6aa5cSAndroid Build Coastguard Worker -dither ordered Use ordered dithering in color quantization. 368*dfc6aa5cSAndroid Build Coastguard Worker -dither none Do not use dithering in color quantization. 369*dfc6aa5cSAndroid Build Coastguard Worker By default, Floyd-Steinberg dithering is applied when 370*dfc6aa5cSAndroid Build Coastguard Worker quantizing colors; this is slow but usually produces 371*dfc6aa5cSAndroid Build Coastguard Worker the best results. Ordered dither is a compromise 372*dfc6aa5cSAndroid Build Coastguard Worker between speed and quality; no dithering is fast but 373*dfc6aa5cSAndroid Build Coastguard Worker usually looks awful. Note that these switches have 374*dfc6aa5cSAndroid Build Coastguard Worker no effect unless color quantization is being done. 375*dfc6aa5cSAndroid Build Coastguard Worker Ordered dither is only available in -onepass mode. 376*dfc6aa5cSAndroid Build Coastguard Worker 377*dfc6aa5cSAndroid Build Coastguard Worker -map FILE Quantize to the colors used in the specified image 378*dfc6aa5cSAndroid Build Coastguard Worker file. This is useful for producing multiple files 379*dfc6aa5cSAndroid Build Coastguard Worker with identical color maps, or for forcing a predefined 380*dfc6aa5cSAndroid Build Coastguard Worker set of colors to be used. The FILE must be a GIF 381*dfc6aa5cSAndroid Build Coastguard Worker or PPM file. This option overrides -colors and 382*dfc6aa5cSAndroid Build Coastguard Worker -onepass. 383*dfc6aa5cSAndroid Build Coastguard Worker 384*dfc6aa5cSAndroid Build Coastguard Worker -nosmooth Use a faster, lower-quality upsampling routine. 385*dfc6aa5cSAndroid Build Coastguard Worker 386*dfc6aa5cSAndroid Build Coastguard Worker -onepass Use one-pass instead of two-pass color quantization. 387*dfc6aa5cSAndroid Build Coastguard Worker The one-pass method is faster and needs less memory, 388*dfc6aa5cSAndroid Build Coastguard Worker but it produces a lower-quality image. -onepass is 389*dfc6aa5cSAndroid Build Coastguard Worker ignored unless you also say -colors N. Also, 390*dfc6aa5cSAndroid Build Coastguard Worker the one-pass method is always used for grayscale 391*dfc6aa5cSAndroid Build Coastguard Worker output (the two-pass method is no improvement then). 392*dfc6aa5cSAndroid Build Coastguard Worker 393*dfc6aa5cSAndroid Build Coastguard Worker -maxmemory N Set limit for amount of memory to use in processing 394*dfc6aa5cSAndroid Build Coastguard Worker large images. Value is in thousands of bytes, or 395*dfc6aa5cSAndroid Build Coastguard Worker millions of bytes if "M" is attached to the number. 396*dfc6aa5cSAndroid Build Coastguard Worker For example, -max 4m selects 4000000 bytes. If more 397*dfc6aa5cSAndroid Build Coastguard Worker space is needed, an error will occur. 398*dfc6aa5cSAndroid Build Coastguard Worker 399*dfc6aa5cSAndroid Build Coastguard Worker -verbose Enable debug printout. More -v's give more printout. 400*dfc6aa5cSAndroid Build Coastguard Worker or -debug Also, version information is printed at startup. 401*dfc6aa5cSAndroid Build Coastguard Worker 402*dfc6aa5cSAndroid Build Coastguard Worker 403*dfc6aa5cSAndroid Build Coastguard WorkerHINTS FOR CJPEG 404*dfc6aa5cSAndroid Build Coastguard Worker 405*dfc6aa5cSAndroid Build Coastguard WorkerColor GIF files are not the ideal input for JPEG; JPEG is really intended for 406*dfc6aa5cSAndroid Build Coastguard Workercompressing full-color (24-bit) images. In particular, don't try to convert 407*dfc6aa5cSAndroid Build Coastguard Workercartoons, line drawings, and other images that have only a few distinct 408*dfc6aa5cSAndroid Build Coastguard Workercolors. GIF works great on these, JPEG does not. If you want to convert a 409*dfc6aa5cSAndroid Build Coastguard WorkerGIF to JPEG, you should experiment with cjpeg's -quality and -smooth options 410*dfc6aa5cSAndroid Build Coastguard Workerto get a satisfactory conversion. -smooth 10 or so is often helpful. 411*dfc6aa5cSAndroid Build Coastguard Worker 412*dfc6aa5cSAndroid Build Coastguard WorkerAvoid running an image through a series of JPEG compression/decompression 413*dfc6aa5cSAndroid Build Coastguard Workercycles. Image quality loss will accumulate; after ten or so cycles the image 414*dfc6aa5cSAndroid Build Coastguard Workermay be noticeably worse than it was after one cycle. It's best to use a 415*dfc6aa5cSAndroid Build Coastguard Workerlossless format while manipulating an image, then convert to JPEG format when 416*dfc6aa5cSAndroid Build Coastguard Workeryou are ready to file the image away. 417*dfc6aa5cSAndroid Build Coastguard Worker 418*dfc6aa5cSAndroid Build Coastguard WorkerThe -optimize option to cjpeg is worth using when you are making a "final" 419*dfc6aa5cSAndroid Build Coastguard Workerversion for posting or archiving. It's also a win when you are using low 420*dfc6aa5cSAndroid Build Coastguard Workerquality settings to make very small JPEG files; the percentage improvement 421*dfc6aa5cSAndroid Build Coastguard Workeris often a lot more than it is on larger files. (At present, -optimize 422*dfc6aa5cSAndroid Build Coastguard Workermode is always selected when generating progressive JPEG files.) 423*dfc6aa5cSAndroid Build Coastguard Worker 424*dfc6aa5cSAndroid Build Coastguard Worker 425*dfc6aa5cSAndroid Build Coastguard WorkerHINTS FOR DJPEG 426*dfc6aa5cSAndroid Build Coastguard Worker 427*dfc6aa5cSAndroid Build Coastguard WorkerTo get a quick preview of an image, use the -grayscale and/or -scale switches. 428*dfc6aa5cSAndroid Build Coastguard Worker"-grayscale -scale 1/8" is the fastest case. 429*dfc6aa5cSAndroid Build Coastguard Worker 430*dfc6aa5cSAndroid Build Coastguard WorkerSeveral options are available that trade off image quality to gain speed. 431*dfc6aa5cSAndroid Build Coastguard Worker"-fast" turns on the recommended settings. 432*dfc6aa5cSAndroid Build Coastguard Worker 433*dfc6aa5cSAndroid Build Coastguard Worker"-dct fast" and/or "-nosmooth" gain speed at a small sacrifice in quality. 434*dfc6aa5cSAndroid Build Coastguard WorkerWhen producing a color-quantized image, "-onepass -dither ordered" is fast but 435*dfc6aa5cSAndroid Build Coastguard Workermuch lower quality than the default behavior. "-dither none" may give 436*dfc6aa5cSAndroid Build Coastguard Workeracceptable results in two-pass mode, but is seldom tolerable in one-pass mode. 437*dfc6aa5cSAndroid Build Coastguard Worker 438*dfc6aa5cSAndroid Build Coastguard Worker 439*dfc6aa5cSAndroid Build Coastguard WorkerHINTS FOR BOTH PROGRAMS 440*dfc6aa5cSAndroid Build Coastguard Worker 441*dfc6aa5cSAndroid Build Coastguard WorkerIf the memory needed by cjpeg or djpeg exceeds the limit specified by 442*dfc6aa5cSAndroid Build Coastguard Worker-maxmemory, an error will occur. You can leave out -progressive and -optimize 443*dfc6aa5cSAndroid Build Coastguard Worker(for cjpeg) or specify -onepass (for djpeg) to reduce memory usage. 444*dfc6aa5cSAndroid Build Coastguard Worker 445*dfc6aa5cSAndroid Build Coastguard WorkerOn machines that have "environment" variables, you can define the environment 446*dfc6aa5cSAndroid Build Coastguard Workervariable JPEGMEM to set the default memory limit. The value is specified as 447*dfc6aa5cSAndroid Build Coastguard Workerdescribed for the -maxmemory switch. JPEGMEM overrides the default value 448*dfc6aa5cSAndroid Build Coastguard Workerspecified when the program was compiled, and itself is overridden by an 449*dfc6aa5cSAndroid Build Coastguard Workerexplicit -maxmemory switch. 450*dfc6aa5cSAndroid Build Coastguard Worker 451*dfc6aa5cSAndroid Build Coastguard Worker 452*dfc6aa5cSAndroid Build Coastguard WorkerJPEGTRAN 453*dfc6aa5cSAndroid Build Coastguard Worker 454*dfc6aa5cSAndroid Build Coastguard Workerjpegtran performs various useful transformations of JPEG files. 455*dfc6aa5cSAndroid Build Coastguard WorkerIt can translate the coded representation from one variant of JPEG to another, 456*dfc6aa5cSAndroid Build Coastguard Workerfor example from baseline JPEG to progressive JPEG or vice versa. It can also 457*dfc6aa5cSAndroid Build Coastguard Workerperform some rearrangements of the image data, for example turning an image 458*dfc6aa5cSAndroid Build Coastguard Workerfrom landscape to portrait format by rotation. For EXIF files and JPEG files 459*dfc6aa5cSAndroid Build Coastguard Workercontaining Exif data, you may prefer to use exiftran instead. 460*dfc6aa5cSAndroid Build Coastguard Worker 461*dfc6aa5cSAndroid Build Coastguard Workerjpegtran works by rearranging the compressed data (DCT coefficients), without 462*dfc6aa5cSAndroid Build Coastguard Workerever fully decoding the image. Therefore, its transformations are lossless: 463*dfc6aa5cSAndroid Build Coastguard Workerthere is no image degradation at all, which would not be true if you used 464*dfc6aa5cSAndroid Build Coastguard Workerdjpeg followed by cjpeg to accomplish the same conversion. But by the same 465*dfc6aa5cSAndroid Build Coastguard Workertoken, jpegtran cannot perform lossy operations such as changing the image 466*dfc6aa5cSAndroid Build Coastguard Workerquality. However, while the image data is losslessly transformed, metadata 467*dfc6aa5cSAndroid Build Coastguard Workercan be removed. See the -copy option for specifics. 468*dfc6aa5cSAndroid Build Coastguard Worker 469*dfc6aa5cSAndroid Build Coastguard Workerjpegtran uses a command line syntax similar to cjpeg or djpeg. 470*dfc6aa5cSAndroid Build Coastguard WorkerOn most systems, you say: 471*dfc6aa5cSAndroid Build Coastguard Worker jpegtran [switches] [inputfile] >outputfile 472*dfc6aa5cSAndroid Build Coastguard WorkerIf you defined TWO_FILE_COMMANDLINE when compiling the program, you can instead 473*dfc6aa5cSAndroid Build Coastguard Workersay: 474*dfc6aa5cSAndroid Build Coastguard Worker jpegtran [switches] inputfile outputfile 475*dfc6aa5cSAndroid Build Coastguard Workerwhere both the input and output files are JPEG files. 476*dfc6aa5cSAndroid Build Coastguard Worker 477*dfc6aa5cSAndroid Build Coastguard WorkerTo specify the coded JPEG representation used in the output file, 478*dfc6aa5cSAndroid Build Coastguard Workerjpegtran accepts a subset of the switches recognized by cjpeg: 479*dfc6aa5cSAndroid Build Coastguard Worker -optimize Perform optimization of entropy encoding parameters. 480*dfc6aa5cSAndroid Build Coastguard Worker -progressive Create progressive JPEG file. 481*dfc6aa5cSAndroid Build Coastguard Worker -arithmetic Use arithmetic coding. 482*dfc6aa5cSAndroid Build Coastguard Worker -restart N Emit a JPEG restart marker every N MCU rows, or every 483*dfc6aa5cSAndroid Build Coastguard Worker N MCU blocks if "B" is attached to the number. 484*dfc6aa5cSAndroid Build Coastguard Worker -scans file Use the scan script given in the specified text file. 485*dfc6aa5cSAndroid Build Coastguard WorkerSee the previous discussion of cjpeg for more details about these switches. 486*dfc6aa5cSAndroid Build Coastguard WorkerIf you specify none of these switches, you get a plain baseline-JPEG output 487*dfc6aa5cSAndroid Build Coastguard Workerfile. The quality setting and so forth are determined by the input file. 488*dfc6aa5cSAndroid Build Coastguard Worker 489*dfc6aa5cSAndroid Build Coastguard WorkerThe image can be losslessly transformed by giving one of these switches: 490*dfc6aa5cSAndroid Build Coastguard Worker -flip horizontal Mirror image horizontally (left-right). 491*dfc6aa5cSAndroid Build Coastguard Worker -flip vertical Mirror image vertically (top-bottom). 492*dfc6aa5cSAndroid Build Coastguard Worker -rotate 90 Rotate image 90 degrees clockwise. 493*dfc6aa5cSAndroid Build Coastguard Worker -rotate 180 Rotate image 180 degrees. 494*dfc6aa5cSAndroid Build Coastguard Worker -rotate 270 Rotate image 270 degrees clockwise (or 90 ccw). 495*dfc6aa5cSAndroid Build Coastguard Worker -transpose Transpose image (across UL-to-LR axis). 496*dfc6aa5cSAndroid Build Coastguard Worker -transverse Transverse transpose (across UR-to-LL axis). 497*dfc6aa5cSAndroid Build Coastguard Worker 498*dfc6aa5cSAndroid Build Coastguard WorkerThe transpose transformation has no restrictions regarding image dimensions. 499*dfc6aa5cSAndroid Build Coastguard WorkerThe other transformations operate rather oddly if the image dimensions are not 500*dfc6aa5cSAndroid Build Coastguard Workera multiple of the iMCU size (usually 8 or 16 pixels), because they can only 501*dfc6aa5cSAndroid Build Coastguard Workertransform complete blocks of DCT coefficient data in the desired way. 502*dfc6aa5cSAndroid Build Coastguard Worker 503*dfc6aa5cSAndroid Build Coastguard Workerjpegtran's default behavior when transforming an odd-size image is designed 504*dfc6aa5cSAndroid Build Coastguard Workerto preserve exact reversibility and mathematical consistency of the 505*dfc6aa5cSAndroid Build Coastguard Workertransformation set. As stated, transpose is able to flip the entire image 506*dfc6aa5cSAndroid Build Coastguard Workerarea. Horizontal mirroring leaves any partial iMCU column at the right edge 507*dfc6aa5cSAndroid Build Coastguard Workeruntouched, but is able to flip all rows of the image. Similarly, vertical 508*dfc6aa5cSAndroid Build Coastguard Workermirroring leaves any partial iMCU row at the bottom edge untouched, but is 509*dfc6aa5cSAndroid Build Coastguard Workerable to flip all columns. The other transforms can be built up as sequences 510*dfc6aa5cSAndroid Build Coastguard Workerof transpose and flip operations; for consistency, their actions on edge 511*dfc6aa5cSAndroid Build Coastguard Workerpixels are defined to be the same as the end result of the corresponding 512*dfc6aa5cSAndroid Build Coastguard Workertranspose-and-flip sequence. 513*dfc6aa5cSAndroid Build Coastguard Worker 514*dfc6aa5cSAndroid Build Coastguard WorkerFor practical use, you may prefer to discard any untransformable edge pixels 515*dfc6aa5cSAndroid Build Coastguard Workerrather than having a strange-looking strip along the right and/or bottom edges 516*dfc6aa5cSAndroid Build Coastguard Workerof a transformed image. To do this, add the -trim switch: 517*dfc6aa5cSAndroid Build Coastguard Worker -trim Drop non-transformable edge blocks. 518*dfc6aa5cSAndroid Build Coastguard WorkerObviously, a transformation with -trim is not reversible, so strictly speaking 519*dfc6aa5cSAndroid Build Coastguard Workerjpegtran with this switch is not lossless. Also, the expected mathematical 520*dfc6aa5cSAndroid Build Coastguard Workerequivalences between the transformations no longer hold. For example, 521*dfc6aa5cSAndroid Build Coastguard Worker"-rot 270 -trim" trims only the bottom edge, but "-rot 90 -trim" followed by 522*dfc6aa5cSAndroid Build Coastguard Worker"-rot 180 -trim" trims both edges. 523*dfc6aa5cSAndroid Build Coastguard Worker 524*dfc6aa5cSAndroid Build Coastguard WorkerIf you are only interested in perfect transformations, add the -perfect switch: 525*dfc6aa5cSAndroid Build Coastguard Worker -perfect Fail with an error if the transformation is not 526*dfc6aa5cSAndroid Build Coastguard Worker perfect. 527*dfc6aa5cSAndroid Build Coastguard WorkerFor example, you may want to do 528*dfc6aa5cSAndroid Build Coastguard Worker jpegtran -rot 90 -perfect foo.jpg || djpeg foo.jpg | pnmflip -r90 | cjpeg 529*dfc6aa5cSAndroid Build Coastguard Workerto do a perfect rotation, if available, or an approximated one if not. 530*dfc6aa5cSAndroid Build Coastguard Worker 531*dfc6aa5cSAndroid Build Coastguard WorkerThis version of jpegtran also offers a lossless crop option, which discards 532*dfc6aa5cSAndroid Build Coastguard Workerdata outside of a given image region but losslessly preserves what is inside. 533*dfc6aa5cSAndroid Build Coastguard WorkerLike the rotate and flip transforms, lossless crop is restricted by the current 534*dfc6aa5cSAndroid Build Coastguard WorkerJPEG format; the upper left corner of the selected region must fall on an iMCU 535*dfc6aa5cSAndroid Build Coastguard Workerboundary. If it doesn't, then it is silently moved up and/or left to the 536*dfc6aa5cSAndroid Build Coastguard Workernearest iMCU boundary (the lower right corner is unchanged.) Thus, the output 537*dfc6aa5cSAndroid Build Coastguard Workerimage covers at least the requested region, but it may cover more. The 538*dfc6aa5cSAndroid Build Coastguard Workeradjustment of the region dimensions may be optionally disabled by attaching an 539*dfc6aa5cSAndroid Build Coastguard Worker'f' character ("force") to the width or height number. 540*dfc6aa5cSAndroid Build Coastguard Worker 541*dfc6aa5cSAndroid Build Coastguard WorkerThe image can be losslessly cropped by giving the switch: 542*dfc6aa5cSAndroid Build Coastguard Worker -crop WxH+X+Y Crop to a rectangular region of width W and height H, 543*dfc6aa5cSAndroid Build Coastguard Worker starting at point X,Y. 544*dfc6aa5cSAndroid Build Coastguard Worker 545*dfc6aa5cSAndroid Build Coastguard WorkerIf W or H is larger than the width/height of the input image, then the output 546*dfc6aa5cSAndroid Build Coastguard Workerimage is expanded in size, and the expanded region is filled in with zeros 547*dfc6aa5cSAndroid Build Coastguard Worker(neutral gray). Attaching an 'f' character ("flatten") to the width number 548*dfc6aa5cSAndroid Build Coastguard Workerwill cause each block in the expanded region to be filled in with the DC 549*dfc6aa5cSAndroid Build Coastguard Workercoefficient of the nearest block in the input image rather than grayed out. 550*dfc6aa5cSAndroid Build Coastguard WorkerAttaching an 'r' character ("reflect") to the width number will cause the 551*dfc6aa5cSAndroid Build Coastguard Workerexpanded region to be filled in with repeated reflections of the input image 552*dfc6aa5cSAndroid Build Coastguard Workerrather than grayed out. 553*dfc6aa5cSAndroid Build Coastguard Worker 554*dfc6aa5cSAndroid Build Coastguard WorkerA complementary lossless wipe option is provided to discard (gray out) data 555*dfc6aa5cSAndroid Build Coastguard Workerinside a given image region while losslessly preserving what is outside: 556*dfc6aa5cSAndroid Build Coastguard Worker -wipe WxH+X+Y Wipe (gray out) a rectangular region of width W and 557*dfc6aa5cSAndroid Build Coastguard Worker height H from the input image, starting at point X,Y. 558*dfc6aa5cSAndroid Build Coastguard Worker 559*dfc6aa5cSAndroid Build Coastguard WorkerAttaching an 'f' character ("flatten") to the width number will cause the 560*dfc6aa5cSAndroid Build Coastguard Workerregion to be filled with the average of adjacent blocks rather than grayed out. 561*dfc6aa5cSAndroid Build Coastguard WorkerIf the wipe region and the region outside the wipe region, when adjusted to the 562*dfc6aa5cSAndroid Build Coastguard Workernearest iMCU boundary, form two horizontally adjacent rectangles, then 563*dfc6aa5cSAndroid Build Coastguard Workerattaching an 'r' character ("reflect") to the width number will cause the wipe 564*dfc6aa5cSAndroid Build Coastguard Workerregion to be filled with repeated reflections of the outside region rather than 565*dfc6aa5cSAndroid Build Coastguard Workergrayed out. 566*dfc6aa5cSAndroid Build Coastguard Worker 567*dfc6aa5cSAndroid Build Coastguard WorkerA lossless drop option is also provided, which allows another JPEG image to be 568*dfc6aa5cSAndroid Build Coastguard Workerinserted ("dropped") into the input image data at a given position, replacing 569*dfc6aa5cSAndroid Build Coastguard Workerthe existing image data at that position: 570*dfc6aa5cSAndroid Build Coastguard Worker -drop +X+Y filename Drop (insert) another image at point X,Y 571*dfc6aa5cSAndroid Build Coastguard Worker 572*dfc6aa5cSAndroid Build Coastguard WorkerBoth the input image and the drop image must have the same subsampling level. 573*dfc6aa5cSAndroid Build Coastguard WorkerIt is best if they also have the same quantization (quality.) Otherwise, the 574*dfc6aa5cSAndroid Build Coastguard Workerquantization of the output image will be adapted to accommodate the higher of 575*dfc6aa5cSAndroid Build Coastguard Workerthe input image quality and the drop image quality. The trim option can be 576*dfc6aa5cSAndroid Build Coastguard Workerused with the drop option to requantize the drop image to match the input 577*dfc6aa5cSAndroid Build Coastguard Workerimage. Note that a grayscale image can be dropped into a full-color image or 578*dfc6aa5cSAndroid Build Coastguard Workervice versa, as long as the full-color image has no vertical subsampling. If 579*dfc6aa5cSAndroid Build Coastguard Workerthe input image is grayscale and the drop image is full-color, then the 580*dfc6aa5cSAndroid Build Coastguard Workerchrominance channels from the drop image will be discarded. 581*dfc6aa5cSAndroid Build Coastguard Worker 582*dfc6aa5cSAndroid Build Coastguard WorkerOther not-strictly-lossless transformation switches are: 583*dfc6aa5cSAndroid Build Coastguard Worker 584*dfc6aa5cSAndroid Build Coastguard Worker -grayscale Force grayscale output. 585*dfc6aa5cSAndroid Build Coastguard WorkerThis option discards the chrominance channels if the input image is YCbCr 586*dfc6aa5cSAndroid Build Coastguard Worker(ie, a standard color JPEG), resulting in a grayscale JPEG file. The 587*dfc6aa5cSAndroid Build Coastguard Workerluminance channel is preserved exactly, so this is a better method of reducing 588*dfc6aa5cSAndroid Build Coastguard Workerto grayscale than decompression, conversion, and recompression. This switch 589*dfc6aa5cSAndroid Build Coastguard Workeris particularly handy for fixing a monochrome picture that was mistakenly 590*dfc6aa5cSAndroid Build Coastguard Workerencoded as a color JPEG. (In such a case, the space savings from getting rid 591*dfc6aa5cSAndroid Build Coastguard Workerof the near-empty chroma channels won't be large; but the decoding time for 592*dfc6aa5cSAndroid Build Coastguard Workera grayscale JPEG is substantially less than that for a color JPEG.) 593*dfc6aa5cSAndroid Build Coastguard Worker 594*dfc6aa5cSAndroid Build Coastguard Workerjpegtran also recognizes these switches that control what to do with "extra" 595*dfc6aa5cSAndroid Build Coastguard Workermarkers, such as comment blocks: 596*dfc6aa5cSAndroid Build Coastguard Worker -copy none Copy no extra markers from source file. This setting 597*dfc6aa5cSAndroid Build Coastguard Worker suppresses all comments and other metadata in the 598*dfc6aa5cSAndroid Build Coastguard Worker source file. 599*dfc6aa5cSAndroid Build Coastguard Worker -copy comments Copy only comment markers. This setting copies 600*dfc6aa5cSAndroid Build Coastguard Worker comments from the source file but discards any other 601*dfc6aa5cSAndroid Build Coastguard Worker metadata. 602*dfc6aa5cSAndroid Build Coastguard Worker -copy icc Copy only ICC profile markers. This setting copies the 603*dfc6aa5cSAndroid Build Coastguard Worker ICC profile from the source file but discards any other 604*dfc6aa5cSAndroid Build Coastguard Worker metadata. 605*dfc6aa5cSAndroid Build Coastguard Worker -copy all Copy all extra markers. This setting preserves 606*dfc6aa5cSAndroid Build Coastguard Worker miscellaneous markers found in the source file, such 607*dfc6aa5cSAndroid Build Coastguard Worker as JFIF thumbnails, Exif data, and Photoshop settings. 608*dfc6aa5cSAndroid Build Coastguard Worker In some files, these extra markers can be sizable. 609*dfc6aa5cSAndroid Build Coastguard Worker Note that this option will copy thumbnails as-is; 610*dfc6aa5cSAndroid Build Coastguard Worker they will not be transformed. 611*dfc6aa5cSAndroid Build Coastguard WorkerThe default behavior is -copy comments. (Note: in IJG releases v6 and v6a, 612*dfc6aa5cSAndroid Build Coastguard Workerjpegtran always did the equivalent of -copy none.) 613*dfc6aa5cSAndroid Build Coastguard Worker 614*dfc6aa5cSAndroid Build Coastguard WorkerAdditional switches recognized by jpegtran are: 615*dfc6aa5cSAndroid Build Coastguard Worker -outfile filename 616*dfc6aa5cSAndroid Build Coastguard Worker -maxmemory N 617*dfc6aa5cSAndroid Build Coastguard Worker -verbose 618*dfc6aa5cSAndroid Build Coastguard Worker -debug 619*dfc6aa5cSAndroid Build Coastguard WorkerThese work the same as in cjpeg or djpeg. 620*dfc6aa5cSAndroid Build Coastguard Worker 621*dfc6aa5cSAndroid Build Coastguard Worker 622*dfc6aa5cSAndroid Build Coastguard WorkerTHE COMMENT UTILITIES 623*dfc6aa5cSAndroid Build Coastguard Worker 624*dfc6aa5cSAndroid Build Coastguard WorkerThe JPEG standard allows "comment" (COM) blocks to occur within a JPEG file. 625*dfc6aa5cSAndroid Build Coastguard WorkerAlthough the standard doesn't actually define what COM blocks are for, they 626*dfc6aa5cSAndroid Build Coastguard Workerare widely used to hold user-supplied text strings. This lets you add 627*dfc6aa5cSAndroid Build Coastguard Workerannotations, titles, index terms, etc to your JPEG files, and later retrieve 628*dfc6aa5cSAndroid Build Coastguard Workerthem as text. COM blocks do not interfere with the image stored in the JPEG 629*dfc6aa5cSAndroid Build Coastguard Workerfile. The maximum size of a COM block is 64K, but you can have as many of 630*dfc6aa5cSAndroid Build Coastguard Workerthem as you like in one JPEG file. 631*dfc6aa5cSAndroid Build Coastguard Worker 632*dfc6aa5cSAndroid Build Coastguard WorkerWe provide two utility programs to display COM block contents and add COM 633*dfc6aa5cSAndroid Build Coastguard Workerblocks to a JPEG file. 634*dfc6aa5cSAndroid Build Coastguard Worker 635*dfc6aa5cSAndroid Build Coastguard Workerrdjpgcom searches a JPEG file and prints the contents of any COM blocks on 636*dfc6aa5cSAndroid Build Coastguard Workerstandard output. The command line syntax is 637*dfc6aa5cSAndroid Build Coastguard Worker rdjpgcom [-raw] [-verbose] [inputfilename] 638*dfc6aa5cSAndroid Build Coastguard WorkerThe switch "-raw" (or just "-r") causes rdjpgcom to output non-printable 639*dfc6aa5cSAndroid Build Coastguard Workercharacters in JPEG comments. These characters are normally escaped for 640*dfc6aa5cSAndroid Build Coastguard Workersecurity reasons. 641*dfc6aa5cSAndroid Build Coastguard WorkerThe switch "-verbose" (or just "-v") causes rdjpgcom to also display the JPEG 642*dfc6aa5cSAndroid Build Coastguard Workerimage dimensions. If you omit the input file name from the command line, 643*dfc6aa5cSAndroid Build Coastguard Workerthe JPEG file is read from standard input. (This may not work on some 644*dfc6aa5cSAndroid Build Coastguard Workeroperating systems, if binary data can't be read from stdin.) 645*dfc6aa5cSAndroid Build Coastguard Worker 646*dfc6aa5cSAndroid Build Coastguard Workerwrjpgcom adds a COM block, containing text you provide, to a JPEG file. 647*dfc6aa5cSAndroid Build Coastguard WorkerOrdinarily, the COM block is added after any existing COM blocks, but you 648*dfc6aa5cSAndroid Build Coastguard Workercan delete the old COM blocks if you wish. wrjpgcom produces a new JPEG 649*dfc6aa5cSAndroid Build Coastguard Workerfile; it does not modify the input file. DO NOT try to overwrite the input 650*dfc6aa5cSAndroid Build Coastguard Workerfile by directing wrjpgcom's output back into it; on most systems this will 651*dfc6aa5cSAndroid Build Coastguard Workerjust destroy your file. 652*dfc6aa5cSAndroid Build Coastguard Worker 653*dfc6aa5cSAndroid Build Coastguard WorkerThe command line syntax for wrjpgcom is similar to cjpeg's. On most systems, 654*dfc6aa5cSAndroid Build Coastguard Workerit is 655*dfc6aa5cSAndroid Build Coastguard Worker wrjpgcom [switches] [inputfilename] 656*dfc6aa5cSAndroid Build Coastguard WorkerThe output file is written to standard output. The input file comes from 657*dfc6aa5cSAndroid Build Coastguard Workerthe named file, or from standard input if no input file is named. 658*dfc6aa5cSAndroid Build Coastguard Worker 659*dfc6aa5cSAndroid Build Coastguard WorkerIf you defined TWO_FILE_COMMANDLINE when compiling the program, the syntax is: 660*dfc6aa5cSAndroid Build Coastguard Worker wrjpgcom [switches] inputfilename outputfilename 661*dfc6aa5cSAndroid Build Coastguard Workerwhere both input and output file names must be given explicitly. 662*dfc6aa5cSAndroid Build Coastguard Worker 663*dfc6aa5cSAndroid Build Coastguard Workerwrjpgcom understands three switches: 664*dfc6aa5cSAndroid Build Coastguard Worker -replace Delete any existing COM blocks from the file. 665*dfc6aa5cSAndroid Build Coastguard Worker -comment "Comment text" Supply new COM text on command line. 666*dfc6aa5cSAndroid Build Coastguard Worker -cfile name Read text for new COM block from named file. 667*dfc6aa5cSAndroid Build Coastguard Worker(Switch names can be abbreviated.) If you have only one line of comment text 668*dfc6aa5cSAndroid Build Coastguard Workerto add, you can provide it on the command line with -comment. The comment 669*dfc6aa5cSAndroid Build Coastguard Workertext must be surrounded with quotes so that it is treated as a single 670*dfc6aa5cSAndroid Build Coastguard Workerargument. Longer comments can be read from a text file. 671*dfc6aa5cSAndroid Build Coastguard Worker 672*dfc6aa5cSAndroid Build Coastguard WorkerIf you give neither -comment nor -cfile, then wrjpgcom will read the comment 673*dfc6aa5cSAndroid Build Coastguard Workertext from standard input. (In this case an input image file name MUST be 674*dfc6aa5cSAndroid Build Coastguard Workersupplied, so that the source JPEG file comes from somewhere else.) You can 675*dfc6aa5cSAndroid Build Coastguard Workerenter multiple lines, up to 64KB worth. Type an end-of-file indicator 676*dfc6aa5cSAndroid Build Coastguard Worker(usually control-D or control-Z) to terminate the comment text entry. 677*dfc6aa5cSAndroid Build Coastguard Worker 678*dfc6aa5cSAndroid Build Coastguard Workerwrjpgcom will not add a COM block if the provided comment string is empty. 679*dfc6aa5cSAndroid Build Coastguard WorkerTherefore -replace -comment "" can be used to delete all COM blocks from a 680*dfc6aa5cSAndroid Build Coastguard Workerfile. 681*dfc6aa5cSAndroid Build Coastguard Worker 682*dfc6aa5cSAndroid Build Coastguard WorkerThese utility programs do not depend on the IJG JPEG library. In 683*dfc6aa5cSAndroid Build Coastguard Workerparticular, the source code for rdjpgcom is intended as an illustration of 684*dfc6aa5cSAndroid Build Coastguard Workerthe minimum amount of code required to parse a JPEG file header correctly. 685