Blame | Last modification | View Log | RSS feed
.TH CJPEG 1 "20 March 1998".SH NAMEcjpeg \- compress an image file to a JPEG file.SH SYNOPSIS.B cjpeg[.I options][.I filename].LP.SH DESCRIPTION.LP.B cjpegcompresses the named image file, or the standard input if no file isnamed, and produces a JPEG/JFIF file on the standard output.The currently supported input file formats are: PPM (PBMPLUS colorformat), PGM (PBMPLUS gray-scale format), BMP, Targa, and RLE (Utah RasterToolkit format). (RLE is supported only if the URT library is available.).SH OPTIONSAll switch names may be abbreviated; for example,.B \-grayscalemay be written.B \-grayor.BR \-gr .Most of the "basic" switches can be abbreviated to as little as one letter.Upper and lower case are equivalent (thus.B \-BMPis the same as.BR \-bmp ).British spellings are also accepted (e.g.,.BR \-greyscale ),though for brevity these are not mentioned below..PPThe basic switches are:.TP.BI \-quality " N"Scale quantization tables to adjust image quality. Quality is 0 (worst) to100 (best); default is 75. (See below for more info.).TP.B \-grayscaleCreate monochrome JPEG file from color input. Be sure to use this switch whencompressing a grayscale BMP file, because.B cjpegisn't bright enough to notice whether a BMP file uses only shades of gray.By saying.BR \-grayscale ,you'll get a smaller JPEG file that takes less time to process..TP.B \-optimizePerform optimization of entropy encoding parameters. Without this, defaultencoding parameters are used..B \-optimizeusually makes the JPEG file a little smaller, but.B cjpegruns somewhat slower and needs much more memory. Image quality and speed ofdecompression are unaffected by.BR \-optimize ..TP.B \-progressiveCreate progressive JPEG file (see below)..TP.B \-targaInput file is Targa format. Targa files that contain an "identification"field will not be automatically recognized by.BR cjpeg ;for such files you must specify.B \-targato make.B cjpegtreat the input as Targa format.For most Targa files, you won't need this switch..PPThe.B \-qualityswitch lets you trade off compressed file size against quality of thereconstructed image: the higher the quality setting, the larger the JPEG file,and the closer the output image will be to the original input. Normally youwant to use the lowest quality setting (smallest file) that decompresses intosomething visually indistinguishable from the original image. For thispurpose the quality setting should be between 50 and 95; the default of 75 isoften about right. If you see defects at.B \-quality75, then go up 5 or 10 counts at a time until you are happy with the outputimage. (The optimal setting will vary from one image to another.).PP.B \-quality100 will generate a quantization table of all 1's, minimizing loss in thequantization step (but there is still information loss in subsampling, as wellas roundoff error). This setting is mainly of interest for experimentalpurposes. Quality values above about 95 are.B notrecommended for normal use; the compressed file size goes up dramatically forhardly any gain in output image quality..PPIn the other direction, quality values below 50 will produce very small filesof low image quality. Settings around 5 to 10 might be useful in preparing anindex of a large image library, for example. Try.B \-quality2 (or so) for some amusing Cubist effects. (Note: qualityvalues below about 25 generate 2-byte quantization tables, which areconsidered optional in the JPEG standard..B cjpegemits a warning message when you give such a quality value, because someother JPEG programs may be unable to decode the resulting file. Use.B \-baselineif you need to ensure compatibility at low quality values.).PPThe.B \-progressiveswitch creates a "progressive JPEG" file. In this type of JPEG file, the datais stored in multiple scans of increasing quality. If the file is beingtransmitted over a slow communications link, the decoder can use the firstscan to display a low-quality image very quickly, and can then improve thedisplay with each subsequent scan. The final image is exactly equivalent to astandard JPEG file of the same quality setting, and the total file size isabout the same --- often a little smaller..B Caution:progressive JPEG is not yet widely implemented, so many decoders will beunable to view a progressive JPEG file at all..PPSwitches for advanced users:.TP.B \-dct intUse integer DCT method (default)..TP.B \-dct fastUse fast integer DCT (less accurate)..TP.B \-dct floatUse floating-point DCT method.The float method is very slightly more accurate than the int method, but ismuch slower unless your machine has very fast floating-point hardware. Alsonote that results of the floating-point method may vary slightly acrossmachines, while the integer methods should give the same results everywhere.The fast integer method is much less accurate than the other two..TP.BI \-restart " N"Emit a JPEG restart marker every N MCU rows, or every N MCU blocks if "B" isattached to the number..B \-restart 0(the default) means no restart markers..TP.BI \-smooth " N"Smooth the input image to eliminate dithering noise. N, ranging from 1 to100, indicates the strength of smoothing. 0 (the default) means no smoothing..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 ..PPThe.B \-restartoption inserts extra markers that allow a JPEG decoder to resynchronize aftera transmission error. Without restart markers, any damage to a compressedfile will usually ruin the image from the point of the error to the end of theimage; with restart markers, the damage is usually confined to the portion ofthe image up to the next restart marker. Of course, the restart markersoccupy extra space. We recommend.B \-restart 1for images that will be transmitted across unreliable networks such as Usenet..PPThe.B \-smoothoption filters the input to eliminate fine-scale noise. This is often usefulwhen converting dithered images to JPEG: a moderate smoothing factor of 10 to50 gets rid of dithering patterns in the input file, resulting in a smallerJPEG file and a better-looking image. Too large a smoothing factor willvisibly blur the image, however..PPSwitches for wizards:.TP.B \-baselineForce baseline-compatible quantization tables to be generated. This clampsquantization values to 8 bits even at low quality settings. (This switch ispoorly named, since it does not ensure that the output is actually baselineJPEG. For example, you can use.B \-baselineand.B \-progressivetogether.).TP.BI \-qtables " file"Use the quantization tables given in the specified text file..TP.BI \-qslots " N[,...]"Select which quantization table to use for each color component..TP.BI \-sample " HxV[,...]"Set JPEG sampling factors for each color component..TP.BI \-scans " file"Use the scan script given in the specified text file..PPThe "wizard" switches are intended for experimentation with JPEG. If youdon't know what you are doing, \fBdon't use them\fR. These switches aredocumented further in the file wizard.doc..SH EXAMPLES.LPThis example compresses the PPM file foo.ppm with a quality factor of60 and saves the output as foo.jpg:.IP.B cjpeg \-quality.I 60 foo.ppm.B >.I foo.jpg.SH HINTSColor GIF files are not the ideal input for JPEG; JPEG is really intended forcompressing full-color (24-bit) images. In particular, don't try to convertcartoons, line drawings, and other images that have only a few distinctcolors. GIF works great on these, JPEG does not. If you want to convert aGIF to JPEG, you should experiment with.BR cjpeg 's.B \-qualityand.B \-smoothoptions to get a satisfactory conversion..B \-smooth 10or so is often helpful..PPAvoid running an image through a series of JPEG compression/decompressioncycles. Image quality loss will accumulate; after ten or so cycles the imagemay be noticeably worse than it was after one cycle. It's best to use alossless format while manipulating an image, then convert to JPEG format whenyou are ready to file the image away..PPThe.B \-optimizeoption to.B cjpegis worth using when you are making a "final" version for posting or archiving.It's also a win when you are using low quality settings to make very smallJPEG files; the percentage improvement is often a lot more than it is onlarger files. (At present,.B \-optimizemode is always selected when generating progressive JPEG files.).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 djpeg (1),.BR jpegtran (1),.BR rdjpgcom (1),.BR wrjpgcom (1).br.BR ppm (5),.BR pgm (5).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..PPGIF input files are no longer supported, to avoid the Unisys LZW patent.Use a Unisys-licensed program if you need to read a GIF file. (Conversionof GIF files to JPEG is usually a bad idea anyway.).PPNot all variants of BMP and Targa file formats are supported..PPThe.B \-targaswitch is not a bug, it's a feature. (It would be a bug if the Targa formatdesigners had not been clueless.).PPStill not as fast as we'd like.