shun-iwasawa 82a8f5
NOTE:  This file was modified by The libjpeg-turbo Project to include only
shun-iwasawa 82a8f5
information relevant to libjpeg-turbo and to wordsmith certain sections.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
USAGE instructions for the Independent JPEG Group's JPEG software
shun-iwasawa 82a8f5
=================================================================
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
This file describes usage of the JPEG conversion programs cjpeg and djpeg,
shun-iwasawa 82a8f5
as well as the utility programs jpegtran, rdjpgcom and wrjpgcom.  (See
shun-iwasawa 82a8f5
the other documentation files if you wish to use the JPEG library within
shun-iwasawa 82a8f5
your own programs.)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
If you are on a Unix machine you may prefer to read the Unix-style manual
shun-iwasawa 82a8f5
pages in files cjpeg.1, djpeg.1, jpegtran.1, rdjpgcom.1, wrjpgcom.1.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
INTRODUCTION
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
These programs implement JPEG image encoding, decoding, and transcoding.
shun-iwasawa 82a8f5
JPEG (pronounced "jay-peg") is a standardized compression method for
shun-iwasawa 82a8f5
full-color and grayscale images.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
GENERAL USAGE
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
We provide two programs, cjpeg to compress an image file into JPEG format,
shun-iwasawa 82a8f5
and djpeg to decompress a JPEG file back into a conventional image format.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
On Unix-like systems, you say:
shun-iwasawa 82a8f5
        cjpeg [switches] [imagefile] >jpegfile
shun-iwasawa 82a8f5
or
shun-iwasawa 82a8f5
        djpeg [switches] [jpegfile]  >imagefile
shun-iwasawa 82a8f5
The programs read the specified input file, or standard input if none is
shun-iwasawa 82a8f5
named.  They always write to standard output (with trace/error messages to
shun-iwasawa 82a8f5
standard error).  These conventions are handy for piping images between
shun-iwasawa 82a8f5
programs.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
On most non-Unix systems, you say:
shun-iwasawa 82a8f5
        cjpeg [switches] imagefile jpegfile
shun-iwasawa 82a8f5
or
shun-iwasawa 82a8f5
        djpeg [switches] jpegfile  imagefile
shun-iwasawa 82a8f5
i.e., both the input and output files are named on the command line.  This
shun-iwasawa 82a8f5
style is a little more foolproof, and it loses no functionality if you don't
shun-iwasawa 82a8f5
have pipes.  (You can get this style on Unix too, if you prefer, by defining
shun-iwasawa 82a8f5
TWO_FILE_COMMANDLINE when you compile the programs; see install.txt.)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
You can also say:
shun-iwasawa 82a8f5
        cjpeg [switches] -outfile jpegfile  imagefile
shun-iwasawa 82a8f5
or
shun-iwasawa 82a8f5
        djpeg [switches] -outfile imagefile  jpegfile
shun-iwasawa 82a8f5
This syntax works on all systems, so it is useful for scripts.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
The currently supported image file formats are: PPM (PBMPLUS color format),
shun-iwasawa 82a8f5
PGM (PBMPLUS grayscale format), BMP, Targa, and RLE (Utah Raster Toolkit
shun-iwasawa 82a8f5
format).  (RLE is supported only if the URT library is available, which it
shun-iwasawa 82a8f5
isn't on most non-Unix systems.)  cjpeg recognizes the input image format
shun-iwasawa 82a8f5
automatically, with the exception of some Targa files.  You have to tell djpeg
shun-iwasawa 82a8f5
which format to generate.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
JPEG files are in the defacto standard JFIF file format.  There are other,
shun-iwasawa 82a8f5
less widely used JPEG-based file formats, but we don't support them.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
All switch names may be abbreviated; for example, -grayscale may be written
shun-iwasawa 82a8f5
-gray or -gr.  Most of the "basic" switches can be abbreviated to as little as
shun-iwasawa 82a8f5
one letter.  Upper and lower case are equivalent (-BMP is the same as -bmp).
shun-iwasawa 82a8f5
British spellings are also accepted (e.g., -greyscale), though for brevity
shun-iwasawa 82a8f5
these are not mentioned below.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
CJPEG DETAILS
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
The basic command line switches for cjpeg are:
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
        -quality N[,...]  Scale quantization tables to adjust image quality.
shun-iwasawa 82a8f5
                          Quality is 0 (worst) to 100 (best); default is 75.
shun-iwasawa 82a8f5
                          (See below for more info.)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
        -grayscale      Create monochrome JPEG file from color input.
shun-iwasawa 82a8f5
                        Be sure to use this switch when compressing a grayscale
shun-iwasawa 82a8f5
                        BMP file, because cjpeg isn't bright enough to notice
shun-iwasawa 82a8f5
                        whether a BMP file uses only shades of gray.  By
shun-iwasawa 82a8f5
                        saying -grayscale, you'll get a smaller JPEG file that
shun-iwasawa 82a8f5
                        takes less time to process.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
        -rgb            Create RGB JPEG file.
shun-iwasawa 82a8f5
                        Using this switch suppresses the conversion from RGB
shun-iwasawa 82a8f5
                        colorspace input to the default YCbCr JPEG colorspace.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
        -optimize       Perform optimization of entropy encoding parameters.
shun-iwasawa 82a8f5
                        Without this, default encoding parameters are used.
shun-iwasawa 82a8f5
                        -optimize usually makes the JPEG file a little smaller,
shun-iwasawa 82a8f5
                        but cjpeg runs somewhat slower and needs much more
shun-iwasawa 82a8f5
                        memory.  Image quality and speed of decompression are
shun-iwasawa 82a8f5
                        unaffected by -optimize.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
        -progressive    Create progressive JPEG file (see below).
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
        -targa          Input file is Targa format.  Targa files that contain
shun-iwasawa 82a8f5
                        an "identification" field will not be automatically
shun-iwasawa 82a8f5
                        recognized by cjpeg; for such files you must specify
shun-iwasawa 82a8f5
                        -targa to make cjpeg treat the input as Targa format.
shun-iwasawa 82a8f5
                        For most Targa files, you won't need this switch.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
The -quality switch lets you trade off compressed file size against quality of
shun-iwasawa 82a8f5
the reconstructed image: the higher the quality setting, the larger the JPEG
shun-iwasawa 82a8f5
file, and the closer the output image will be to the original input.  Normally
shun-iwasawa 82a8f5
you want to use the lowest quality setting (smallest file) that decompresses
shun-iwasawa 82a8f5
into something visually indistinguishable from the original image.  For this
shun-iwasawa 82a8f5
purpose the quality setting should generally be between 50 and 95 (the default
shun-iwasawa 82a8f5
is 75) for photographic images.  If you see defects at -quality 75, then go up
shun-iwasawa 82a8f5
5 or 10 counts at a time until you are happy with the output image.  (The
shun-iwasawa 82a8f5
optimal setting will vary from one image to another.)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
-quality 100 will generate a quantization table of all 1's, minimizing loss
shun-iwasawa 82a8f5
in the quantization step (but there is still information loss in subsampling,
shun-iwasawa 82a8f5
as well as roundoff error.)  For most images, specifying a quality value above
shun-iwasawa 82a8f5
about 95 will increase the size of the compressed file dramatically, and while
shun-iwasawa 82a8f5
the quality gain from these higher quality values is measurable (using metrics
shun-iwasawa 82a8f5
such as PSNR or SSIM), it is rarely perceivable by human vision.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
In the other direction, quality values below 50 will produce very small files
shun-iwasawa 82a8f5
of low image quality.  Settings around 5 to 10 might be useful in preparing an
shun-iwasawa 82a8f5
index of a large image library, for example.  Try -quality 2 (or so) for some
shun-iwasawa 82a8f5
amusing Cubist effects.  (Note: quality values below about 25 generate 2-byte
shun-iwasawa 82a8f5
quantization tables, which are considered optional in the JPEG standard.
shun-iwasawa 82a8f5
cjpeg emits a warning message when you give such a quality value, because some
shun-iwasawa 82a8f5
other JPEG programs may be unable to decode the resulting file.  Use -baseline
shun-iwasawa 82a8f5
if you need to ensure compatibility at low quality values.)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
The -quality option has been extended in this version of cjpeg to support
shun-iwasawa 82a8f5
separate quality settings for luminance and chrominance (or, in general,
shun-iwasawa 82a8f5
separate settings for every quantization table slot.)  The principle is the
shun-iwasawa 82a8f5
same as chrominance subsampling:  since the human eye is more sensitive to
shun-iwasawa 82a8f5
spatial changes in brightness than spatial changes in color, the chrominance
shun-iwasawa 82a8f5
components can be quantized more than the luminance components without
shun-iwasawa 82a8f5
incurring any visible image quality loss.  However, unlike subsampling, this
shun-iwasawa 82a8f5
feature reduces data in the frequency domain instead of the spatial domain,
shun-iwasawa 82a8f5
which allows for more fine-grained control.  This option is useful in
shun-iwasawa 82a8f5
quality-sensitive applications, for which the artifacts generated by
shun-iwasawa 82a8f5
subsampling may be unacceptable.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
The -quality option accepts a comma-separated list of parameters, which
shun-iwasawa 82a8f5
respectively refer to the quality levels that should be assigned to the
shun-iwasawa 82a8f5
quantization table slots.  If there are more q-table slots than parameters,
shun-iwasawa 82a8f5
then the last parameter is replicated.  Thus, if only one quality parameter is
shun-iwasawa 82a8f5
given, this is used for both luminance and chrominance (slots 0 and 1,
shun-iwasawa 82a8f5
respectively), preserving the legacy behavior of cjpeg v6b and prior.  More (or
shun-iwasawa 82a8f5
customized) quantization tables can be set with the -qtables option and
shun-iwasawa 82a8f5
assigned to components with the -qslots option (see the "wizard" switches
shun-iwasawa 82a8f5
below.)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
JPEG  files  generated  with separate luminance and chrominance quality are
shun-iwasawa 82a8f5
fully compliant with standard JPEG decoders.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
CAUTION: For this setting to be useful, be sure to pass an argument of
shun-iwasawa 82a8f5
-sample 1x1 to cjpeg to disable chrominance subsampling.  Otherwise, the
shun-iwasawa 82a8f5
default subsampling level (2x2, AKA "4:2:0") will be used.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
The -progressive switch creates a "progressive JPEG" file.  In this type of
shun-iwasawa 82a8f5
JPEG file, the data is stored in multiple scans of increasing quality.  If the
shun-iwasawa 82a8f5
file is being transmitted over a slow communications link, the decoder can use
shun-iwasawa 82a8f5
the first scan to display a low-quality image very quickly, and can then
shun-iwasawa 82a8f5
improve the display with each subsequent scan.  The final image is exactly
shun-iwasawa 82a8f5
equivalent to a standard JPEG file of the same quality setting, and the total
shun-iwasawa 82a8f5
file size is about the same --- often a little smaller.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
Switches for advanced users:
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
        -arithmetic     Use arithmetic coding.  CAUTION: arithmetic coded JPEG
shun-iwasawa 82a8f5
                        is not yet widely implemented, so many decoders will
shun-iwasawa 82a8f5
                        be unable to view an arithmetic coded JPEG file at
shun-iwasawa 82a8f5
                        all.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
        -dct int        Use accurate integer DCT method (default).
shun-iwasawa 82a8f5
        -dct fast       Use less accurate integer DCT method [legacy feature].
shun-iwasawa 82a8f5
                        When the Independent JPEG Group's software was first
shun-iwasawa 82a8f5
                        released in 1991, the compression time for a
shun-iwasawa 82a8f5
                        1-megapixel JPEG image on a mainstream PC was measured
shun-iwasawa 82a8f5
                        in minutes.  Thus, the fast integer DCT algorithm
shun-iwasawa 82a8f5
                        provided noticeable performance benefits.  On modern
shun-iwasawa 82a8f5
                        CPUs running libjpeg-turbo, however, the compression
shun-iwasawa 82a8f5
                        time for a 1-megapixel JPEG image is measured in
shun-iwasawa 82a8f5
                        milliseconds, and thus the performance benefits of the
shun-iwasawa 82a8f5
                        fast algorithm are much less noticeable.  On modern
shun-iwasawa 82a8f5
                        x86/x86-64 CPUs that support AVX2 instructions, the
shun-iwasawa 82a8f5
                        fast and int methods have similar performance.  On
shun-iwasawa 82a8f5
                        other types of CPUs, the fast method is generally about
shun-iwasawa 82a8f5
                        5-15% faster than the int method.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
                        For quality levels of 90 and below, there should be
shun-iwasawa 82a8f5
                        little or no perceptible quality difference between the
shun-iwasawa 82a8f5
                        two algorithms.  For quality levels above 90, however,
shun-iwasawa 82a8f5
                        the difference between the fast and int methods becomes
shun-iwasawa 82a8f5
                        more pronounced.  With quality=97, for instance, the
shun-iwasawa 82a8f5
                        fast method incurs generally about a 1-3 dB loss in
shun-iwasawa 82a8f5
                        PSNR relative to the int method, but this can be larger
shun-iwasawa 82a8f5
                        for some images.  Do not use the fast method with
shun-iwasawa 82a8f5
                        quality levels above 97.  The algorithm often
shun-iwasawa 82a8f5
                        degenerates at quality=98 and above and can actually
shun-iwasawa 82a8f5
                        produce a more lossy image than if lower quality levels
shun-iwasawa 82a8f5
                        had been used.  Also, in libjpeg-turbo, the fast method
shun-iwasawa 82a8f5
                        is not fully accelerated for quality levels above 97,
shun-iwasawa 82a8f5
                        so it will be slower than the int method.
shun-iwasawa 82a8f5
        -dct float      Use floating-point DCT method [legacy feature].
shun-iwasawa 82a8f5
                        The float method does not produce significantly more
shun-iwasawa 82a8f5
                        accurate results than the int method, and it is much
shun-iwasawa 82a8f5
                        slower.  The float method may also give different
shun-iwasawa 82a8f5
                        results on different machines due to varying roundoff
shun-iwasawa 82a8f5
                        behavior, whereas the integer methods should give the
shun-iwasawa 82a8f5
                        same results on all machines.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
        -restart N      Emit a JPEG restart marker every N MCU rows, or every
shun-iwasawa 82a8f5
                        N MCU blocks if "B" is attached to the number.
shun-iwasawa 82a8f5
                        -restart 0 (the default) means no restart markers.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
        -smooth N       Smooth the input image to eliminate dithering noise.
shun-iwasawa 82a8f5
                        N, ranging from 1 to 100, indicates the strength of
shun-iwasawa 82a8f5
                        smoothing.  0 (the default) means no smoothing.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
        -maxmemory N    Set limit for amount of memory to use in processing
shun-iwasawa 82a8f5
                        large images.  Value is in thousands of bytes, or
shun-iwasawa 82a8f5
                        millions of bytes if "M" is attached to the number.
shun-iwasawa 82a8f5
                        For example, -max 4m selects 4000000 bytes.  If more
shun-iwasawa 82a8f5
                        space is needed, an error will occur.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
        -verbose        Enable debug printout.  More -v's give more printout.
shun-iwasawa 82a8f5
        or  -debug      Also, version information is printed at startup.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
The -restart option inserts extra markers that allow a JPEG decoder to
shun-iwasawa 82a8f5
resynchronize after a transmission error.  Without restart markers, any damage
shun-iwasawa 82a8f5
to a compressed file will usually ruin the image from the point of the error
shun-iwasawa 82a8f5
to the end of the image; with restart markers, the damage is usually confined
shun-iwasawa 82a8f5
to the portion of the image up to the next restart marker.  Of course, the
shun-iwasawa 82a8f5
restart markers occupy extra space.  We recommend -restart 1 for images that
shun-iwasawa 82a8f5
will be transmitted across unreliable networks such as Usenet.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
The -smooth option filters the input to eliminate fine-scale noise.  This is
shun-iwasawa 82a8f5
often useful when converting dithered images to JPEG: a moderate smoothing
shun-iwasawa 82a8f5
factor of 10 to 50 gets rid of dithering patterns in the input file, resulting
shun-iwasawa 82a8f5
in a smaller JPEG file and a better-looking image.  Too large a smoothing
shun-iwasawa 82a8f5
factor will visibly blur the image, however.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
Switches for wizards:
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
        -baseline       Force baseline-compatible quantization tables to be
shun-iwasawa 82a8f5
                        generated.  This clamps quantization values to 8 bits
shun-iwasawa 82a8f5
                        even at low quality settings.  (This switch is poorly
shun-iwasawa 82a8f5
                        named, since it does not ensure that the output is
shun-iwasawa 82a8f5
                        actually baseline JPEG.  For example, you can use
shun-iwasawa 82a8f5
                        -baseline and -progressive together.)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
        -qtables file   Use the quantization tables given in the specified
shun-iwasawa 82a8f5
                        text file.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
        -qslots N[,...] Select which quantization table to use for each color
shun-iwasawa 82a8f5
                        component.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
        -sample HxV[,...]  Set JPEG sampling factors for each color component.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
        -scans file     Use the scan script given in the specified text file.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
The "wizard" switches are intended for experimentation with JPEG.  If you
shun-iwasawa 82a8f5
don't know what you are doing, DON'T USE THEM.  These switches are documented
shun-iwasawa 82a8f5
further in the file wizard.txt.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
DJPEG DETAILS
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
The basic command line switches for djpeg are:
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
        -colors N       Reduce image to at most N colors.  This reduces the
shun-iwasawa 82a8f5
        or -quantize N  number of colors used in the output image, so that it
shun-iwasawa 82a8f5
                        can be displayed on a colormapped display or stored in
shun-iwasawa 82a8f5
                        a colormapped file format.  For example, if you have
shun-iwasawa 82a8f5
                        an 8-bit display, you'd need to reduce to 256 or fewer
shun-iwasawa 82a8f5
                        colors.  (-colors is the recommended name, -quantize
shun-iwasawa 82a8f5
                        is provided only for backwards compatibility.)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
        -fast           Select recommended processing options for fast, low
shun-iwasawa 82a8f5
                        quality output.  (The default options are chosen for
shun-iwasawa 82a8f5
                        highest quality output.)  Currently, this is equivalent
shun-iwasawa 82a8f5
                        to "-dct fast -nosmooth -onepass -dither ordered".
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
        -grayscale      Force grayscale output even if JPEG file is color.
shun-iwasawa 82a8f5
                        Useful for viewing on monochrome displays; also,
shun-iwasawa 82a8f5
                        djpeg runs noticeably faster in this mode.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
        -rgb            Force RGB output even if JPEG file is grayscale.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
        -scale M/N      Scale the output image by a factor M/N.  Currently
shun-iwasawa 82a8f5
                        the scale factor must be M/8, where M is an integer
shun-iwasawa 82a8f5
                        between 1 and 16 inclusive, or any reduced fraction
shun-iwasawa 82a8f5
                        thereof (such as 1/2, 3/4, etc.  Scaling is handy if
shun-iwasawa 82a8f5
                        the image is larger than your screen; also, djpeg runs
shun-iwasawa 82a8f5
                        much faster when scaling down the output.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
        -bmp            Select BMP output format (Windows flavor).  8-bit
shun-iwasawa 82a8f5
                        colormapped format is emitted if -colors or -grayscale
shun-iwasawa 82a8f5
                        is specified, or if the JPEG file is grayscale;
shun-iwasawa 82a8f5
                        otherwise, 24-bit full-color format is emitted.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
        -gif            Select GIF output format.  Since GIF does not support
shun-iwasawa 82a8f5
                        more than 256 colors, -colors 256 is assumed (unless
shun-iwasawa 82a8f5
                        you specify a smaller number of colors).  If you
shun-iwasawa 82a8f5
                        specify -fast, the default number of colors is 216.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
        -os2            Select BMP output format (OS/2 1.x flavor).  8-bit
shun-iwasawa 82a8f5
                        colormapped format is emitted if -colors or -grayscale
shun-iwasawa 82a8f5
                        is specified, or if the JPEG file is grayscale;
shun-iwasawa 82a8f5
                        otherwise, 24-bit full-color format is emitted.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
        -pnm            Select PBMPLUS (PPM/PGM) output format (this is the
shun-iwasawa 82a8f5
                        default format).  PGM is emitted if the JPEG file is
shun-iwasawa 82a8f5
                        grayscale or if -grayscale is specified; otherwise
shun-iwasawa 82a8f5
                        PPM is emitted.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
        -rle            Select RLE output format.  (Requires URT library.)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
        -targa          Select Targa output format.  Grayscale format is
shun-iwasawa 82a8f5
                        emitted if the JPEG file is grayscale or if
shun-iwasawa 82a8f5
                        -grayscale is specified; otherwise, colormapped format
shun-iwasawa 82a8f5
                        is emitted if -colors is specified; otherwise, 24-bit
shun-iwasawa 82a8f5
                        full-color format is emitted.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
Switches for advanced users:
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
        -dct int        Use accurate integer DCT method (default).
shun-iwasawa 82a8f5
        -dct fast       Use less accurate integer DCT method [legacy feature].
shun-iwasawa 82a8f5
                        When the Independent JPEG Group's software was first
shun-iwasawa 82a8f5
                        released in 1991, the decompression time for a
shun-iwasawa 82a8f5
                        1-megapixel JPEG image on a mainstream PC was measured
shun-iwasawa 82a8f5
                        in minutes.  Thus, the fast integer DCT algorithm
shun-iwasawa 82a8f5
                        provided noticeable performance benefits.  On modern
shun-iwasawa 82a8f5
                        CPUs running libjpeg-turbo, however, the decompression
shun-iwasawa 82a8f5
                        time for a 1-megapixel JPEG image is measured in
shun-iwasawa 82a8f5
                        milliseconds, and thus the performance benefits of the
shun-iwasawa 82a8f5
                        fast algorithm are much less noticeable.  On modern
shun-iwasawa 82a8f5
                        x86/x86-64 CPUs that support AVX2 instructions, the
shun-iwasawa 82a8f5
                        fast and int methods have similar performance.  On
shun-iwasawa 82a8f5
                        other types of CPUs, the fast method is generally about
shun-iwasawa 82a8f5
                        5-15% faster than the int method.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
                        If the JPEG image was compressed using a quality level
shun-iwasawa 82a8f5
                        of 85 or below, then there should be little or no
shun-iwasawa 82a8f5
                        perceptible quality difference between the two
shun-iwasawa 82a8f5
                        algorithms.  When decompressing images that were
shun-iwasawa 82a8f5
                        compressed using quality levels above 85, however, the
shun-iwasawa 82a8f5
                        difference between the fast and int methods becomes
shun-iwasawa 82a8f5
                        more pronounced.  With images compressed using
shun-iwasawa 82a8f5
                        quality=97, for instance, the fast method incurs
shun-iwasawa 82a8f5
                        generally about a 4-6 dB loss in PSNR relative to the
shun-iwasawa 82a8f5
                        int method, but this can be larger for some images.  If
shun-iwasawa 82a8f5
                        you can avoid it, do not use the fast method when
shun-iwasawa 82a8f5
                        decompressing images that were compressed using quality
shun-iwasawa 82a8f5
                        levels above 97.  The algorithm often degenerates for
shun-iwasawa 82a8f5
                        such images and can actually produce a more lossy
shun-iwasawa 82a8f5
                        output image than if the JPEG image had been compressed
shun-iwasawa 82a8f5
                        using lower quality levels.
shun-iwasawa 82a8f5
        -dct float      Use floating-point DCT method [legacy feature].
shun-iwasawa 82a8f5
                        The float method does not produce significantly more
shun-iwasawa 82a8f5
                        accurate results than the int method, and it is much
shun-iwasawa 82a8f5
                        slower.  The float method may also give different
shun-iwasawa 82a8f5
                        results on different machines due to varying roundoff
shun-iwasawa 82a8f5
                        behavior, whereas the integer methods should give the
shun-iwasawa 82a8f5
                        same results on all machines.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
        -dither fs      Use Floyd-Steinberg dithering in color quantization.
shun-iwasawa 82a8f5
        -dither ordered Use ordered dithering in color quantization.
shun-iwasawa 82a8f5
        -dither none    Do not use dithering in color quantization.
shun-iwasawa 82a8f5
                        By default, Floyd-Steinberg dithering is applied when
shun-iwasawa 82a8f5
                        quantizing colors; this is slow but usually produces
shun-iwasawa 82a8f5
                        the best results.  Ordered dither is a compromise
shun-iwasawa 82a8f5
                        between speed and quality; no dithering is fast but
shun-iwasawa 82a8f5
                        usually looks awful.  Note that these switches have
shun-iwasawa 82a8f5
                        no effect unless color quantization is being done.
shun-iwasawa 82a8f5
                        Ordered dither is only available in -onepass mode.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
        -map FILE       Quantize to the colors used in the specified image
shun-iwasawa 82a8f5
                        file.  This is useful for producing multiple files
shun-iwasawa 82a8f5
                        with identical color maps, or for forcing a predefined
shun-iwasawa 82a8f5
                        set of colors to be used.  The FILE must be a GIF
shun-iwasawa 82a8f5
                        or PPM file.  This option overrides -colors and
shun-iwasawa 82a8f5
                        -onepass.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
        -nosmooth       Use a faster, lower-quality upsampling routine.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
        -onepass        Use one-pass instead of two-pass color quantization.
shun-iwasawa 82a8f5
                        The one-pass method is faster and needs less memory,
shun-iwasawa 82a8f5
                        but it produces a lower-quality image.  -onepass is
shun-iwasawa 82a8f5
                        ignored unless you also say -colors N.  Also,
shun-iwasawa 82a8f5
                        the one-pass method is always used for grayscale
shun-iwasawa 82a8f5
                        output (the two-pass method is no improvement then).
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
        -maxmemory N    Set limit for amount of memory to use in processing
shun-iwasawa 82a8f5
                        large images.  Value is in thousands of bytes, or
shun-iwasawa 82a8f5
                        millions of bytes if "M" is attached to the number.
shun-iwasawa 82a8f5
                        For example, -max 4m selects 4000000 bytes.  If more
shun-iwasawa 82a8f5
                        space is needed, an error will occur.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
        -verbose        Enable debug printout.  More -v's give more printout.
shun-iwasawa 82a8f5
        or  -debug      Also, version information is printed at startup.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
HINTS FOR CJPEG
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
Color GIF files are not the ideal input for JPEG; JPEG is really intended for
shun-iwasawa 82a8f5
compressing full-color (24-bit) images.  In particular, don't try to convert
shun-iwasawa 82a8f5
cartoons, line drawings, and other images that have only a few distinct
shun-iwasawa 82a8f5
colors.  GIF works great on these, JPEG does not.  If you want to convert a
shun-iwasawa 82a8f5
GIF to JPEG, you should experiment with cjpeg's -quality and -smooth options
shun-iwasawa 82a8f5
to get a satisfactory conversion.  -smooth 10 or so is often helpful.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
Avoid running an image through a series of JPEG compression/decompression
shun-iwasawa 82a8f5
cycles.  Image quality loss will accumulate; after ten or so cycles the image
shun-iwasawa 82a8f5
may be noticeably worse than it was after one cycle.  It's best to use a
shun-iwasawa 82a8f5
lossless format while manipulating an image, then convert to JPEG format when
shun-iwasawa 82a8f5
you are ready to file the image away.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
The -optimize option to cjpeg is worth using when you are making a "final"
shun-iwasawa 82a8f5
version for posting or archiving.  It's also a win when you are using low
shun-iwasawa 82a8f5
quality settings to make very small JPEG files; the percentage improvement
shun-iwasawa 82a8f5
is often a lot more than it is on larger files.  (At present, -optimize
shun-iwasawa 82a8f5
mode is always selected when generating progressive JPEG files.)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
Support for GIF input files was removed in cjpeg v6b due to concerns over
shun-iwasawa 82a8f5
the Unisys LZW patent.  Although this patent expired in 2006, cjpeg still
shun-iwasawa 82a8f5
lacks GIF support, for these historical reasons.  (Conversion of GIF files to
shun-iwasawa 82a8f5
JPEG is usually a bad idea anyway.)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
HINTS FOR DJPEG
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
To get a quick preview of an image, use the -grayscale and/or -scale switches.
shun-iwasawa 82a8f5
"-grayscale -scale 1/8" is the fastest case.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
Several options are available that trade off image quality to gain speed.
shun-iwasawa 82a8f5
"-fast" turns on the recommended settings.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
"-dct fast" and/or "-nosmooth" gain speed at a small sacrifice in quality.
shun-iwasawa 82a8f5
When producing a color-quantized image, "-onepass -dither ordered" is fast but
shun-iwasawa 82a8f5
much lower quality than the default behavior.  "-dither none" may give
shun-iwasawa 82a8f5
acceptable results in two-pass mode, but is seldom tolerable in one-pass mode.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
To avoid the Unisys LZW patent (now expired), djpeg produces uncompressed GIF
shun-iwasawa 82a8f5
files.  These are larger than they should be, but are readable by standard GIF
shun-iwasawa 82a8f5
decoders.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
HINTS FOR BOTH PROGRAMS
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
If the memory needed by cjpeg or djpeg exceeds the limit specified by
shun-iwasawa 82a8f5
-maxmemory, an error will occur.  You can leave out -progressive and -optimize
shun-iwasawa 82a8f5
(for cjpeg) or specify -onepass (for djpeg) to reduce memory usage.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
On machines that have "environment" variables, you can define the environment
shun-iwasawa 82a8f5
variable JPEGMEM to set the default memory limit.  The value is specified as
shun-iwasawa 82a8f5
described for the -maxmemory switch.  JPEGMEM overrides the default value
shun-iwasawa 82a8f5
specified when the program was compiled, and itself is overridden by an
shun-iwasawa 82a8f5
explicit -maxmemory switch.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
JPEGTRAN
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
jpegtran performs various useful transformations of JPEG files.
shun-iwasawa 82a8f5
It can translate the coded representation from one variant of JPEG to another,
shun-iwasawa 82a8f5
for example from baseline JPEG to progressive JPEG or vice versa.  It can also
shun-iwasawa 82a8f5
perform some rearrangements of the image data, for example turning an image
shun-iwasawa 82a8f5
from landscape to portrait format by rotation.  For EXIF files and JPEG files
shun-iwasawa 82a8f5
containing Exif data, you may prefer to use exiftran instead.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
jpegtran works by rearranging the compressed data (DCT coefficients), without
shun-iwasawa 82a8f5
ever fully decoding the image.  Therefore, its transformations are lossless:
shun-iwasawa 82a8f5
there is no image degradation at all, which would not be true if you used
shun-iwasawa 82a8f5
djpeg followed by cjpeg to accomplish the same conversion.  But by the same
shun-iwasawa 82a8f5
token, jpegtran cannot perform lossy operations such as changing the image
shun-iwasawa 82a8f5
quality.  However, while the image data is losslessly transformed, metadata
shun-iwasawa 82a8f5
can be removed.  See the -copy option for specifics.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
jpegtran uses a command line syntax similar to cjpeg or djpeg.
shun-iwasawa 82a8f5
On Unix-like systems, you say:
shun-iwasawa 82a8f5
        jpegtran [switches] [inputfile] >outputfile
shun-iwasawa 82a8f5
On most non-Unix systems, you say:
shun-iwasawa 82a8f5
        jpegtran [switches] inputfile outputfile
shun-iwasawa 82a8f5
where both the input and output files are JPEG files.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
To specify the coded JPEG representation used in the output file,
shun-iwasawa 82a8f5
jpegtran accepts a subset of the switches recognized by cjpeg:
shun-iwasawa 82a8f5
        -optimize       Perform optimization of entropy encoding parameters.
shun-iwasawa 82a8f5
        -progressive    Create progressive JPEG file.
shun-iwasawa 82a8f5
        -arithmetic     Use arithmetic coding.
shun-iwasawa 82a8f5
        -restart N      Emit a JPEG restart marker every N MCU rows, or every
shun-iwasawa 82a8f5
                        N MCU blocks if "B" is attached to the number.
shun-iwasawa 82a8f5
        -scans file     Use the scan script given in the specified text file.
shun-iwasawa 82a8f5
See the previous discussion of cjpeg for more details about these switches.
shun-iwasawa 82a8f5
If you specify none of these switches, you get a plain baseline-JPEG output
shun-iwasawa 82a8f5
file.  The quality setting and so forth are determined by the input file.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
The image can be losslessly transformed by giving one of these switches:
shun-iwasawa 82a8f5
        -flip horizontal        Mirror image horizontally (left-right).
shun-iwasawa 82a8f5
        -flip vertical          Mirror image vertically (top-bottom).
shun-iwasawa 82a8f5
        -rotate 90              Rotate image 90 degrees clockwise.
shun-iwasawa 82a8f5
        -rotate 180             Rotate image 180 degrees.
shun-iwasawa 82a8f5
        -rotate 270             Rotate image 270 degrees clockwise (or 90 ccw).
shun-iwasawa 82a8f5
        -transpose              Transpose image (across UL-to-LR axis).
shun-iwasawa 82a8f5
        -transverse             Transverse transpose (across UR-to-LL axis).
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
The transpose transformation has no restrictions regarding image dimensions.
shun-iwasawa 82a8f5
The other transformations operate rather oddly if the image dimensions are not
shun-iwasawa 82a8f5
a multiple of the iMCU size (usually 8 or 16 pixels), because they can only
shun-iwasawa 82a8f5
transform complete blocks of DCT coefficient data in the desired way.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
jpegtran's default behavior when transforming an odd-size image is designed
shun-iwasawa 82a8f5
to preserve exact reversibility and mathematical consistency of the
shun-iwasawa 82a8f5
transformation set.  As stated, transpose is able to flip the entire image
shun-iwasawa 82a8f5
area.  Horizontal mirroring leaves any partial iMCU column at the right edge
shun-iwasawa 82a8f5
untouched, but is able to flip all rows of the image.  Similarly, vertical
shun-iwasawa 82a8f5
mirroring leaves any partial iMCU row at the bottom edge untouched, but is
shun-iwasawa 82a8f5
able to flip all columns.  The other transforms can be built up as sequences
shun-iwasawa 82a8f5
of transpose and flip operations; for consistency, their actions on edge
shun-iwasawa 82a8f5
pixels are defined to be the same as the end result of the corresponding
shun-iwasawa 82a8f5
transpose-and-flip sequence.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
For practical use, you may prefer to discard any untransformable edge pixels
shun-iwasawa 82a8f5
rather than having a strange-looking strip along the right and/or bottom edges
shun-iwasawa 82a8f5
of a transformed image.  To do this, add the -trim switch:
shun-iwasawa 82a8f5
        -trim           Drop non-transformable edge blocks.
shun-iwasawa 82a8f5
Obviously, a transformation with -trim is not reversible, so strictly speaking
shun-iwasawa 82a8f5
jpegtran with this switch is not lossless.  Also, the expected mathematical
shun-iwasawa 82a8f5
equivalences between the transformations no longer hold.  For example,
shun-iwasawa 82a8f5
"-rot 270 -trim" trims only the bottom edge, but "-rot 90 -trim" followed by
shun-iwasawa 82a8f5
"-rot 180 -trim" trims both edges.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
If you are only interested in perfect transformations, add the -perfect switch:
shun-iwasawa 82a8f5
        -perfect        Fail with an error if the transformation is not
shun-iwasawa 82a8f5
                        perfect.
shun-iwasawa 82a8f5
For example, you may want to do
shun-iwasawa 82a8f5
  jpegtran -rot 90 -perfect foo.jpg || djpeg foo.jpg | pnmflip -r90 | cjpeg
shun-iwasawa 82a8f5
to do a perfect rotation, if available, or an approximated one if not.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
This version of jpegtran also offers a lossless crop option, which discards
shun-iwasawa 82a8f5
data outside of a given image region but losslessly preserves what is inside.
shun-iwasawa 82a8f5
Like the rotate and flip transforms, lossless crop is restricted by the current
shun-iwasawa 82a8f5
JPEG format; the upper left corner of the selected region must fall on an iMCU
shun-iwasawa 82a8f5
boundary.  If it doesn't, then it is silently moved up and/or left to the
shun-iwasawa 82a8f5
nearest iMCU boundary (the lower right corner is unchanged.)  Thus, the output
shun-iwasawa 82a8f5
image covers at least the requested region, but it may cover more.  The
shun-iwasawa 82a8f5
adjustment of the region dimensions may be optionally disabled by attaching an
shun-iwasawa 82a8f5
'f' character ("force") to the width or height number.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
The image can be losslessly cropped by giving the switch:
shun-iwasawa 82a8f5
        -crop WxH+X+Y   Crop to a rectangular region of width W and height H,
shun-iwasawa 82a8f5
                        starting at point X,Y.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
Other not-strictly-lossless transformation switches are:
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
        -grayscale      Force grayscale output.
shun-iwasawa 82a8f5
This option discards the chrominance channels if the input image is YCbCr
shun-iwasawa 82a8f5
(ie, a standard color JPEG), resulting in a grayscale JPEG file.  The
shun-iwasawa 82a8f5
luminance channel is preserved exactly, so this is a better method of reducing
shun-iwasawa 82a8f5
to grayscale than decompression, conversion, and recompression.  This switch
shun-iwasawa 82a8f5
is particularly handy for fixing a monochrome picture that was mistakenly
shun-iwasawa 82a8f5
encoded as a color JPEG.  (In such a case, the space savings from getting rid
shun-iwasawa 82a8f5
of the near-empty chroma channels won't be large; but the decoding time for
shun-iwasawa 82a8f5
a grayscale JPEG is substantially less than that for a color JPEG.)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
jpegtran also recognizes these switches that control what to do with "extra"
shun-iwasawa 82a8f5
markers, such as comment blocks:
shun-iwasawa 82a8f5
        -copy none      Copy no extra markers from source file.  This setting
shun-iwasawa 82a8f5
                        suppresses all comments and other metadata in the
shun-iwasawa 82a8f5
                        source file.
shun-iwasawa 82a8f5
        -copy comments  Copy only comment markers.  This setting copies
shun-iwasawa 82a8f5
                        comments from the source file but discards any other
shun-iwasawa 82a8f5
                        metadata.
shun-iwasawa 82a8f5
        -copy all       Copy all extra markers.  This setting preserves
shun-iwasawa 82a8f5
                        miscellaneous markers found in the source file, such
shun-iwasawa 82a8f5
                        as JFIF thumbnails, Exif data, and Photoshop settings.
shun-iwasawa 82a8f5
                        In some files, these extra markers can be sizable.
shun-iwasawa 82a8f5
                        Note that this option will copy thumbnails as-is;
shun-iwasawa 82a8f5
                        they will not be transformed.
shun-iwasawa 82a8f5
The default behavior is -copy comments.  (Note: in IJG releases v6 and v6a,
shun-iwasawa 82a8f5
jpegtran always did the equivalent of -copy none.)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
Additional switches recognized by jpegtran are:
shun-iwasawa 82a8f5
        -outfile filename
shun-iwasawa 82a8f5
        -maxmemory N
shun-iwasawa 82a8f5
        -verbose
shun-iwasawa 82a8f5
        -debug
shun-iwasawa 82a8f5
These work the same as in cjpeg or djpeg.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
THE COMMENT UTILITIES
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
The JPEG standard allows "comment" (COM) blocks to occur within a JPEG file.
shun-iwasawa 82a8f5
Although the standard doesn't actually define what COM blocks are for, they
shun-iwasawa 82a8f5
are widely used to hold user-supplied text strings.  This lets you add
shun-iwasawa 82a8f5
annotations, titles, index terms, etc to your JPEG files, and later retrieve
shun-iwasawa 82a8f5
them as text.  COM blocks do not interfere with the image stored in the JPEG
shun-iwasawa 82a8f5
file.  The maximum size of a COM block is 64K, but you can have as many of
shun-iwasawa 82a8f5
them as you like in one JPEG file.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
We provide two utility programs to display COM block contents and add COM
shun-iwasawa 82a8f5
blocks to a JPEG file.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
rdjpgcom searches a JPEG file and prints the contents of any COM blocks on
shun-iwasawa 82a8f5
standard output.  The command line syntax is
shun-iwasawa 82a8f5
        rdjpgcom [-raw] [-verbose] [inputfilename]
shun-iwasawa 82a8f5
The switch "-raw" (or just "-r") causes rdjpgcom to output non-printable
shun-iwasawa 82a8f5
characters in JPEG comments.  These characters are normally escaped for
shun-iwasawa 82a8f5
security reasons.
shun-iwasawa 82a8f5
The switch "-verbose" (or just "-v") causes rdjpgcom to also display the JPEG
shun-iwasawa 82a8f5
image dimensions.  If you omit the input file name from the command line,
shun-iwasawa 82a8f5
the JPEG file is read from standard input.  (This may not work on some
shun-iwasawa 82a8f5
operating systems, if binary data can't be read from stdin.)
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
wrjpgcom adds a COM block, containing text you provide, to a JPEG file.
shun-iwasawa 82a8f5
Ordinarily, the COM block is added after any existing COM blocks, but you
shun-iwasawa 82a8f5
can delete the old COM blocks if you wish.  wrjpgcom produces a new JPEG
shun-iwasawa 82a8f5
file; it does not modify the input file.  DO NOT try to overwrite the input
shun-iwasawa 82a8f5
file by directing wrjpgcom's output back into it; on most systems this will
shun-iwasawa 82a8f5
just destroy your file.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
The command line syntax for wrjpgcom is similar to cjpeg's.  On Unix-like
shun-iwasawa 82a8f5
systems, it is
shun-iwasawa 82a8f5
        wrjpgcom [switches] [inputfilename]
shun-iwasawa 82a8f5
The output file is written to standard output.  The input file comes from
shun-iwasawa 82a8f5
the named file, or from standard input if no input file is named.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
On most non-Unix systems, the syntax is
shun-iwasawa 82a8f5
        wrjpgcom [switches] inputfilename outputfilename
shun-iwasawa 82a8f5
where both input and output file names must be given explicitly.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
wrjpgcom understands three switches:
shun-iwasawa 82a8f5
        -replace                 Delete any existing COM blocks from the file.
shun-iwasawa 82a8f5
        -comment "Comment text"  Supply new COM text on command line.
shun-iwasawa 82a8f5
        -cfile name              Read text for new COM block from named file.
shun-iwasawa 82a8f5
(Switch names can be abbreviated.)  If you have only one line of comment text
shun-iwasawa 82a8f5
to add, you can provide it on the command line with -comment.  The comment
shun-iwasawa 82a8f5
text must be surrounded with quotes so that it is treated as a single
shun-iwasawa 82a8f5
argument.  Longer comments can be read from a text file.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
If you give neither -comment nor -cfile, then wrjpgcom will read the comment
shun-iwasawa 82a8f5
text from standard input.  (In this case an input image file name MUST be
shun-iwasawa 82a8f5
supplied, so that the source JPEG file comes from somewhere else.)  You can
shun-iwasawa 82a8f5
enter multiple lines, up to 64KB worth.  Type an end-of-file indicator
shun-iwasawa 82a8f5
(usually control-D or control-Z) to terminate the comment text entry.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
wrjpgcom will not add a COM block if the provided comment string is empty.
shun-iwasawa 82a8f5
Therefore -replace -comment "" can be used to delete all COM blocks from a
shun-iwasawa 82a8f5
file.
shun-iwasawa 82a8f5
shun-iwasawa 82a8f5
These utility programs do not depend on the IJG JPEG library.  In
shun-iwasawa 82a8f5
particular, the source code for rdjpgcom is intended as an illustration of
shun-iwasawa 82a8f5
the minimum amount of code required to parse a JPEG file header correctly.