home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-12-14 | 57.5 KB | 1,477 lines |
- Newsgroups: comp.sources.misc
- Path: sparky!kent
- From: cristy@eplrx7.es.duPont.com (John Cristy)
- Subject: v34i052: imagemagick - X11 image processing and display v2.2, Part24/26
- Message-ID: <1992Dec15.035913.23089@sparky.imd.sterling.com>
- Followup-To: comp.sources.d
- X-Md4-Signature: ddc213416383218cd7dc1a0c01672bc8
- Sender: kent@sparky.imd.sterling.com (Kent Landfield)
- Organization: Sterling Software
- References: <csm-v34i028=imagemagick.141926@sparky.IMD.Sterling.COM>
- Date: Tue, 15 Dec 1992 03:59:13 GMT
- Approved: kent@sparky.imd.sterling.com
- Lines: 1462
-
- Submitted-by: cristy@eplrx7.es.duPont.com (John Cristy)
- Posting-number: Volume 34, Issue 52
- Archive-name: imagemagick/part24
- Environment: UNIX, VMS, X11, SGI, DEC, Cray, Sun, Vax
-
- #!/bin/sh
- # this is Part.24 (part 24 of a multipart archive)
- # do not concatenate these parts, unpack them in order with /bin/sh
- # file ImageMagick/montage.man continued
- #
- if test ! -r _shar_seq_.tmp; then
- echo 'Please unpack part 1 first!'
- exit 1
- fi
- (read Scheck
- if test "$Scheck" != 24; then
- echo Please unpack part "$Scheck" next!
- exit 1
- else
- exit 0
- fi
- ) < _shar_seq_.tmp || exit 1
- if test ! -f _shar_wnt_.tmp; then
- echo 'x - still skipping ImageMagick/montage.man'
- else
- echo 'x - continuing file ImageMagick/montage.man'
- sed 's/^X//' << 'SHAR_EOF' >> 'ImageMagick/montage.man' &&
- \fP-background\fP command line argument or X resource. The width and
- height of the composite image is determined by the title specified,
- the maximum tile size, the number of tiles per row, the tile border
- width and height, the image border width, and the label height. The
- number of tiles per row specifies how many images are to appear in each
- row of the composite image. The default is to have an equal number of
- images in each row and column of the composite. A specific value is
- specified with \fB-tiles_per_row\fP. The tile border width and height,
- and the image border width defaults to the value of the X resource
- \fB-borderwidth\fP. It can be changed with the \fB-borderwidth\fP or
- \fB-geometry\fP command line argument or X resource. The label height
- is determined by the font you specify with the \fB-font\fP command line
- argument or X resource. If you do not specify a font, a font is
- choosen that allows the name of the image to fit the maximum width of a
- tiled area. The label colors is determined by the \fB-background\fP
- and \fB-foreground\fP command line argument or X resource. Note, that
- if the background and foreground colors are the same, labels will not
- appear.
- X
- Initially, the composite image title is placed at the top if one is
- specified (refer to \fB-foreground\fP X resource). Next, each image is
- set onto the composite image, surrounded by its border color, with its
- name centered just below it. The individual images are left-justified
- within the width of the tiled area. The order of the images is the
- same as they appear on the command line unless the images have a scene
- keyword. If a scene number is specified in each image, then the images
- are tiled onto the composite in the order of their scene number. Finally,
- the last argument on the command line is the name assigned to the
- composite image. By default, the image is written in the \fIMIFF\fP format
- and can be viewed or printed with \fBdisplay(1)\fP.
- X
- You can specify a particular image format by prefixing \fIfile\fP with
- the image type and a colon (i.e. mtv:image) or specify the image type
- as the filename suffix (i.e. image.mtv). See \fBconvert(1)\fP for a
- list of valid image formats. If \fIfile\fP has the extension \fB.Z\fP,
- the file size is reduced using Lempel-Ziv coding with \fBcompress\fP.
- If \fIfile\fP already exists, you will be prompted as to whether it
- should be overwritten.
- .SH EXAMPLES
- To create a montage of a cockatoo, a parrot, and a hummingbird and write
- it to a file called birds, use:
- .PP
- X montage cockatoo.miff parrot.miff hummingbird.miff birds.miff
- .PP
- To tile several bird images so that they are at most 256 pixels in width and
- 192 pixels in height, surrounded by a red border, and separated by
- 10 pixels of background color, use:
- .PP
- X montage -geometry 256x192+10+10 -bordercolor red birds.* montage.miff
- X
- To create an unlabeled parrot image, 640 by 480 pixels, and surrounded
- by a border of black, use:
- .PP
- X montage +display -geometry 640x480 -bordercolor black parrot.miff bird.miff
- .SH OPTIONS
- .TP 5
- .B "-aspect_ratio
- The original aspect ratio of each image is adhered to unless
- \fB\+aspect_ratio\fP is specfified.
- X
- That is, as each image is tiled onto the composite image it is scaled
- to fit the maximum width and height of the tiled area while respecting
- the aspect ratio of the original image. \fB\+aspect_ratio\fP means the
- image is scaled to exactly the dimensions of the tiled image as
- specified by \fB\-geometry\fP.
- .TP 5
- .B "-clip \fI<width>x<height>+<x offset>+<y offset>\fP"
- preferred size and location of the clipped image. See \fBX(1)\fP for details
- about the geometry specification.
- X
- Use clipping to tile only a particular area of an image.
- X
- The equivalent X resource for this option is \fBclipGeometry\fP
- (class \fBClipGeometry\fP). See \fBX RESOURCES\fP for details.
- .TP 5
- .B "-colors \fIvalue\fP"
- preferred number of colors in the image.
- X
- The actual number of colors in the image may be less than your request,
- but never more. Note, this is a color reduction option. Images with
- less unique colors than specified with this option will remain unchanged.
- Refer to \fBQuantize(9)\fP for more details.
- X
- Note, options \fB-dither\fP, \fB-colorspace\fP, and \fB-treedepth\fP affect
- the color reduction algorithm.
- .TP 5
- .B "-colorspace \fIvalue\fP"
- the type of colorspace: \fIGRAY\fP, \fIRGB\fP, \fIXYZ\fP, \fIYIQ\fP, or
- \fIYUV\fP.
- X
- Color reduction, by default, takes place in the RGB color space.
- Empirical evidence suggests that distances in color spaces such as YUV
- or YIQ correspond to perceptual color differences more closely
- than do distances in RGB space. These color spaces may give better
- results when color reducing an image. Refer to \fBQuantize(9)\fP for
- more details.
- X
- The \fB-colors\fP or \fB-monochrome\fP option is required for this option
- to take effect.
- .TP 5
- .B "-compose \fIoperator\fP"
- the type of image composition.
- X
- By default, each of the composite image pixels are replaced by the
- cooresponding image tile pixel. You can choose an alternate composite
- operation:
- X
- X over
- X in
- X out
- X atop
- X xor
- X plus
- X minus
- X add
- X subtract
- X difference
- X replace
- .PP
- The operations behaves as follows:
- .TP 9
- .B over
- The result will be the union of the two image shapes, with \fIimage\fP
- obscuring \fIcomposite image\fP in the region of overlap.
- .TP 9
- .B in
- The result is simply \fIimage\fP cut by the shape of \fIimage
- window\fP. None of the image data of \fIcomposite image\fP will be in the
- result.
- .TP 9
- .B out
- The resulting image is \fIimage\fP with the shape of \fIcomposite image\fP
- cut out.
- .TP 9
- .B atop
- The result is the same shape as image \fIcomposite image\fP, with
- \fIimage\fP obscuring \fIcomposite image\fP where the image shapes
- overlap. Note this differs from \fBover\fP because the portion of
- \fIimage\fP outside \fIcomposite image\fP's shape does not appear in the
- result.
- .TP 9
- .B xor
- The result is the image data from both \fIimage\fP and \fIcomposite image\fP
- that is outside the overlap region. The overlap region will be blank.
- .TP 9
- .B plus
- The result is just the sum of the image data. Output values are
- clipped to 255 (no overflow). This operation is independent
- of the alpha channels.
- .TP 9
- .B minus
- The result of \fIimage\fP \- \fIcomposite image\fP, with underflow clipped
- to zero. The alpha channel is ignored (set to 255, full coverage).
- .TP 9
- .B add
- The result of \fIimage\fP + \fIcomposite image\fP, with overflow wrapping
- around (\fImod\fP 256).
- .TP 9
- .B subtract
- The result of \fIimage\fP - \fIcomposite image\fP, with underflow wrapping
- around (\fImod\fP 256). The \fBadd\fP and \fBsubtract\fP operators can
- be used to perform reversible transformations.
- .TP 9
- .B difference
- The result of abs(\fIimage\fP \- \fIcomposite image\fP). This is useful
- for comparing two very similar images.
- .TP 9
- .B replace
- The resulting image is \fIcomposite image\fP replaced with \fIimage\fP.
- Here the alpha information is ignored.
- .PP
- The image compositor requires an alpha, or matte channel in the image
- for some operations. This extra channel usually defines a mask which
- represents a sort of a cookie-cutter for the image. This is the case
- when alpha is 255 (full coverage) for pixels inside the shape, zero
- outside, and between zero and 255 on the boundary. If \fIimage\fP does
- not have an alpha channel, it is initialized with 0 for any pixel
- matching in color to pixel location (0,0), otherwise 255 (to work
- properly \fBborderwidth\fP must be 0).
- .TP 5
- .B "-compress \fItype\fP"
- the type of image compression: \fIQEncoded\fP or \fIRunlengthEncoded\fP.
- X
- This option specifies the type of image compression for the composite
- image. See \fBMIFF(5)\fP for details.
- X
- Specify \fB\+compress\fP to store the binary image in an uncompressed format.
- The default is the compression type of the specified image file.
- .TP 5
- .B "-density \fI<width>x<height>
- vertical and horizonal density of the image.
- X
- This option specifies an image density whose interpretation changes
- with the type of image. The default is 72 dots per inch in the
- horizonal and vertical direction for Postscript. Text files default to
- 80 characters in width and 60 lines in height. Use this option to
- alter the default density.
- .TP 5
- .B "-display \fIhost:display[.screen]\fP"
- specifies the X server to contact; see \fBX(1)\fP.
- X
- Specify \fB+display\fP if an X server is not available. The label font
- is obtained from the X server. If none is available, the composite image
- will not have labels.
- .TP 5
- .B "-dither"
- apply Floyd/Steinberg error diffusion to the image.
- X
- The basic strategy of dithering is to trade intensity resolution for
- spatial resolution by averaging the intensities of several neighboring
- pixels. Images which suffer from severe contouring when reducing colors
- can be improved with this option.
- X
- The \fB-colors\fP or \fB-monochrome\fP option is required
- for this option to take effect.
- .TP 5
- .B "-gamma \fIvalue\fP"
- level of gamma correction.
- X
- The same color image displayed on two different workstations may look
- different due to differences in the display monitor. Use gamma
- correction to adjust for this color difference. Reasonable values
- extend from 0.8 to 2.3.
- .TP 5
- .B "-geometry \fI<width>x<height>+<border width>+<border height>\fP"
- preferred tile and border size of each tile of the composite image.
- See \fBX(1)\fP for details about the geometry specification. By default,
- the tile size is 256x256 and there is no border.
- X
- The tile size you specify is a maximum size. Each image is scaled to
- fit the maximum size while still retaining its original aspect ratio.
- Each image is surrounded by a border whose size in pixels is specified
- as \fI<border width>\fP and \fI<border height>\fP and whose color is
- the background color.
- X
- The equivalent X resource for this option is \fBimageGeometry\fP
- (class \fBImageGeometry\fP). See \fBX RESOURCES\fP for details.
- .TP 5
- .B "-gravity \fIdirection\fP"
- direction image gravitates to within a tile. See \fBX(1)\fP for details
- about the gravity specification.
- X
- A tile of the composite image is a fixed width and height. However,
- the image within the tile may not fill it completely (see
- \fB-aspect_ratio\fP). The direction you specify indicates where to
- position the image within the tile. For example \fICenter\fP gravity
- forces the image to be centered within the tile. By default, the image
- gravity is \fICenter\fP.
- .TP 5
- .B "-monochrome"
- transform the image to black and white.
- X
- Monochrome images can benefit from error diffusion. Use \fB-dither\fP with
- this option to diffuse the error.
- .TP 5
- .B "-rotate \fIdegrees\fP"
- apply Paeth image rotation to the image.
- .TP 5
- .B "-tiles_per_row \fIvalue\fP"
- specifies how many images are to appear in each row of the composite image.
- The default is to have an equal number of images in each row and column of
- the composite.
- .TP 5
- .B "-treedepth \fIvalue\fP"
- Normally, this integer value is zero or one. A zero or one tells
- \fIMontage\fP to choose a optimal tree depth for the color reduction
- algorithm.
- X
- An optimal depth generally allows the best representation of the source
- image with the fastest computational speed and the least amount of
- memory. However, the default depth is inappropriate for some images.
- To assure the best representation, try values between 2 and 8 for this
- parameter. Refer to \fBQuantize(9)\fP for more details.
- X
- The \fB-colors\fP or \fB-monochrome\fP option is required for this option
- to take effect.
- .TP 5
- .B -verbose
- print detailed information about the image.
- X
- This information is printed: image scene number; image name; image size;
- the image class (\fIDirectClass\fP or \fIPseudoClass\fP); the total
- number of unique colors; and the number of seconds to read and write the
- image.
- .PP
- In addition to those listed above, you can specify these standard X
- resources as command line options: -background, -bordercolor, -borderwidth,
- -font, -foreground, -title.
- See \fBX RESOURCES\fP for details.
- .PP
- Any option you specify on the command line remains in effect until it is
- explicitly changed by specifying the option again with a different effect.
- For example, to montage two images, the first with 32 colors and the
- second with only 16 colors, use:
- .PP
- X montage -colors 32 cockatoo.1 -colors 16 cockatoo.2 cockatoo.miff
- .PP
- Change \fI-\fP to \fI\+\fP in any option above to reverse its effect.
- For example, specify \fB\+dither\fP to not apply error diffusion to an
- image.
- .PP
- \fIfile\fP specifies the image filename. By default, the image format
- is determined by its magic number. To specify a particular image
- format, precede the filename with an image format name and a colon
- (i.e. mtv:image) or as the filename suffix (i.e. image.mtv). See
- \fBconvert(1)\fP for a list of valid image formats. Specify \fIfile\fP
- as \fI-\fP for standard input or output. If \fIfile\fP has the
- extension \fB.Z\fP, the file is decoded with \fIuncompress\fP.
- X
- Note, a composite MIFF image displayed to an X server with
- \fIdisplay\fB behaves differently than other images. You can think of
- the composite as a visual image directory. Choose a particular tile of
- the composite and press a button to display it. See \fBdisplay(1)\fP
- and \fBMIFF(5)\fP for details.
- X
- .SH "X RESOURCES"
- \fIMontage\fP options can appear on the command line or in your X
- resource file. Options on the command line supersede values specified
- in your X resource file. See \fBX(1)\fP for more information on X
- resources.
- X
- All \fImontage\fP options have a corresponding X resource. In addition,
- \fImontage\fP uses the following X resources:
- .TP 5
- .B background (\fPclass\fB Background)
- Specifies the preferred color to use for the composite image background. The
- default is black.
- .TP 5
- .B borderColor (\fPclass\fB BorderColor)
- Specifies the preferred color to use for the composite image border. The
- default is white.
- .TP 5
- .B borderWidth (\fPclass\fB BorderWidth)
- Specifies the width in pixels of the composite image border. The default is 2.
- .TP 5
- .B font (\fPclass\fB Font)
- Specifies the name of the preferred font to use when displaying text
- within the composite image. The default is 9x15, fixed, or 5x8 determined by
- the composite image size.
- .TP 5
- .B foreground (\fPclass\fB Foreground)
- Specifies the preferred color to use for text within the composite image. The
- default is white.
- .TP 5
- .B title (\fPclass\fB Title)
- This resource specifies the title to be placed at the top of the composite
- image. The default is not to place a title at the top of the composite image.
- .SH ENVIRONMENT
- .TP 5
- .B DISPLAY
- To get the default host, display number, and screen.
- .SH SEE ALSO
- display(1), mogrify(1), convert(1), X(1), Quantize(9), MIFF(5), compress(1)
- .SH COPYRIGHT
- Copyright 1992 E. I. du Pont de Nemours & Company
- .PP
- Permission to use, copy, modify, distribute, and sell this software and
- its documentation for any purpose is hereby granted without fee,
- provided that the above copyright notice appear in all copies and that
- both that copyright notice and this permission notice appear in
- supporting documentation, and that the name of E. I. du Pont de Nemours
- & Company not be used in advertising or publicity pertaining to
- distribution of the software without specific, written prior
- permission. E. I. du Pont de Nemours & Company makes no representations
- about the suitability of this software for any purpose. It is provided
- "as is" without express or implied warranty.
- .PP
- E. I. du Pont de Nemours & Company disclaims all warranties with regard
- to this software, including all implied warranties of merchantability
- and fitness, in no event shall E. I. du Pont de Nemours & Company be
- liable for any special, indirect or consequential damages or any
- damages whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action, arising
- out of or in connection with the use or performance of this software.
- .SH ACKNOWLEDGEMENTS
- The MIT X Consortium for making network transparent graphics a reality.
- .PP
- Michael Halle, Spatial Imaging Group at MIT, for the initial
- implementation of Alan Paeth's image rotation algorithm.
- .PP
- David Pensak, E. I. du Pont de Nemours & Company, for providing a
- computing environment that made this program possible.
- .PP
- Paul Raveling, USC Information Sciences Institute, for the original
- idea of using space subdivision for the color reduction algorithm.
- .SH AUTHORS
- John Cristy, E.I. du Pont de Nemours & Company Incorporated
- SHAR_EOF
- echo 'File ImageMagick/montage.man is complete' &&
- chmod 0644 ImageMagick/montage.man ||
- echo 'restore of ImageMagick/montage.man failed'
- Wc_c="`wc -c < 'ImageMagick/montage.man'`"
- test 17572 -eq "$Wc_c" ||
- echo 'ImageMagick/montage.man: original size 17572, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= ImageMagick/PreRvIcccm.h ==============
- if test -f 'ImageMagick/PreRvIcccm.h' -a X"$1" != X"-c"; then
- echo 'x - skipping ImageMagick/PreRvIcccm.h (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting ImageMagick/PreRvIcccm.h (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/PreRvIcccm.h' &&
- #ifdef PRE_R5_ICCCM
- /*
- X Compatability defines for pre X11R5 ICCCM.
- */
- extern XrmDatabase
- X XrmGetDatabase();
- #endif
- X
- #ifdef PRE_R4_ICCCM
- /*
- X Compatability defines for pre X11R4 ICCCM.
- */
- #ifdef vms
- #define XMaxRequestSize(display) 16384
- #endif
- X
- #define XInductColormap(display,colormap) XInstallColormap(display,colormap)
- #define XUninductColormap(display,colormap) XUninstallColormap(display,colormap)
- X
- typedef struct _XTextProperty
- {
- X unsigned char
- X *value;
- X
- X Atom
- X encoding;
- X
- X int
- X format;
- X
- X unsigned long
- X nitems;
- } XTextProperty;
- X
- /*
- X Pre R4 ICCCM compatibility routines.
- */
- char
- X *XResourceManagerString();
- X
- extern int
- X XWMGeometry();
- X
- extern Status
- X XGetRGBColormaps(),
- X XGetWMName(),
- X XReconfigureWMWindow(),
- X XSetWMProtocols(),
- X XWithdrawWindow();
- X
- extern XClassHint
- X *XAllocClassHint();
- X
- extern XIconSize
- X *XAllocIconSize();
- X
- extern XSizeHints
- X *XAllocSizeHints();
- X
- extern XStandardColormap
- X *XAllocStandardColormap();
- X
- extern XWMHints
- X *XAllocWMHints();
- X
- extern VisualID
- X XVisualIDFromVisual();
- X
- extern void
- X XrmDestroyDatabase(),
- X XSetWMProperties();
- #else
- #define XInductColormap(display,colormap)
- #define XUninductColormap(display,colormap)
- #endif
- SHAR_EOF
- chmod 0644 ImageMagick/PreRvIcccm.h ||
- echo 'restore of ImageMagick/PreRvIcccm.h failed'
- Wc_c="`wc -c < 'ImageMagick/PreRvIcccm.h'`"
- test 1201 -eq "$Wc_c" ||
- echo 'ImageMagick/PreRvIcccm.h: original size 1201, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= ImageMagick/quantize.man ==============
- if test -f 'ImageMagick/quantize.man' -a X"$1" != X"-c"; then
- echo 'x - skipping ImageMagick/quantize.man (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting ImageMagick/quantize.man (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/quantize.man' &&
- .ad l
- .nh
- .TH QUANTIZE 9 "10 October 1992" "ImageMagick"
- .SH NAME
- Quantize - ImageMagick's color reduction algorithm.
- .SH SYNOPSIS
- .B #include <image.h>
- .SH DESCRIPTION
- This document describes how \fIImageMagick\fP performs color reduction on an
- image. To fully understand this document, you should have a knowledge
- of basic imaging techniques and the tree data structure and terminology.
- .PP
- For purposes of color allocation, an image is a set of \fIn\fP pixels,
- where each pixel is a point in RGB space. RGB space is a 3-dimensional
- vector space, and each pixel, \fIp\d\s-3i\s0\u\fP, is defined by an
- ordered triple of red, green, and blue coordinates, (\fIr\d\s-3i\s0\u,
- g\d\s-3i\s0\u, b\d\s-3i\s0\u\fP).
- .PP
- Each primary color component (red, green, or blue) represents an
- intensity which varies linearly from 0 to a maximum value,
- \fIc\d\s-3max\s0\u\fP, which corresponds to full saturation of that
- color. Color allocation is defined over a domain consisting of the
- cube in RGB space with opposite vertices at (0,0,0) and
- (\fIc\d\s-3max\s0\u,c\d\s-3max\s0\u,c\d\s-3max\s0\u\fP). \fIImageMagick\fP
- requires \fIc\d\s-3max\s0\u = 255\fP.
- .PP
- The algorithm maps this domain onto a tree in which each node
- represents a cube within that domain. In the following discussion,
- these cubes are defined by the coordinate of two opposite vertices: The
- vertex nearest the origin in RGB space and the vertex farthest from the
- origin.
- .PP
- The tree's root node represents the the entire domain, (0,0,0) through
- (\fIc\d\s-3max\s0\u,c\d\s-3max\s0\u,c\d\s-3max\s0\u\fP). Each lower level in
- the tree is generated by subdividing one node's cube into eight smaller
- cubes of equal size. This corresponds to bisecting the parent cube
- with planes passing through the midpoints of each edge.
- .PP
- The basic algorithm operates in three phases: \fBClassification,
- Reduction\fP, and \fBAssignment\fP. \fBClassification\fP builds a
- color description tree for the image. \fBReduction\fP collapses the
- tree until the number it represents, at most, is the number of colors
- desired in the output image. \fBAssignment\fP defines the output
- image's color map and sets each pixel's color by reclassification in
- the reduced tree.
- .PP
- \fBClassification\fP begins by initializing a color description tree of
- sufficient depth to represent each possible input color in a leaf.
- However, it is impractical to generate a fully-formed color description
- tree in the classification phase for realistic values of
- \fIc\d\s-3max\s0\u\fP. If color components in the input image are
- quantized to \fIk\fP-bit precision, so that \fIc\d\s-3max\s0\u =
- 2\u\s-3k\s0\d-1\fP, the tree would need \fIk\fP levels below the root
- node to allow representing each possible input color in a leaf. This
- becomes prohibitive because the tree's total number of nodes is
- .PP
- X \fI\s+6\(*S\u\s-9 k\d\di=1\s0 8k\fP\s0\u
- .PP
- A complete tree would require 19,173,961 nodes for \fIk = 8,
- c\d\s-3max\s0\u = 255\fP. Therefore, to avoid building a fully
- populated tree, \fIImageMagick\fP: (1) Initializes data structures for
- nodes only as they are needed; (2) Chooses a maximum depth for the tree
- as a function of the desired number of colors in the output image
- (currently \fIlog\d\s-34\s0\u(colormap size)\+2\fP). A tree of this
- depth generally allows the best representation of the source image with
- the fastest computational speed and the least amount of memory.
- However, the default depth is inappropriate for some images.
- Therefore, the caller can request a specific tree depth.
- .PP
- For each pixel in the input image, classification scans downward from
- the root of the color description tree. At each level of the tree, it
- identifies the single node which represents a cube in RGB space
- containing the pixel's color. It updates the following data for each
- such node:
- .TP 5
- .B n\d\s-31\s0\u:
- Number of pixels whose color is contained in the RGB cube which this
- node represents;
- .TP 5
- .B n\d\s-32\s0\u:
- Number of pixels whose color is not represented in a node at lower
- depth in the tree; initially, \fIn\d\s-32\s0\u = 0\fP for all nodes
- except leaves of the tree.
- .TP 5
- .B S\d\s-3r\s0\u, S\d\s-3g\s0\u, S\d\s-3b\s0\u:
- Sums of the red, green, and blue component values for all pixels not
- classified at a lower depth. The combination of these sums and
- \fIn\d\s-32\s0\u\fP will ultimately characterize the mean color of a
- set of pixels represented by this node.
- .PP
- \fBReduction\fP repeatedly prunes the tree until the number of nodes with
- \fIn\d\s-32\s0\u > 0\fP is less than or equal to the maximum number of colors
- allowed in the output image. On any given iteration over the tree, it
- selects those nodes whose \fIn\d\s-31\s0\u\fP count is minimal for pruning and
- merges their color statistics upward. It uses a pruning threshold,
- \fIn\d\s-3p\s0\u\fP, to govern node selection as follows:
- .PP
- X n\d\s-3p\s0\u = 0
- X while number of nodes with (n\d\s-32\s0\u > 0) > required maximum number of colors
- X prune all nodes such that n\d\s-31\s0\u <= n\d\s-3p\s0\u
- X Set n\d\s-3p\s0\u to minimum n\d\s-31\s0\u in remaining nodes
- .PP
- When a node to be pruned has offspring, the pruning procedure invokes
- itself recursively in order to prune the tree from the leaves upward.
- The values of \fIn\d\s-32\s0\u S\d\s-3r\s0\u, S\d\s-3g\s0\u,\fP and
- \fIS\d\s-3b\s0\u\fP in a node being pruned are always added to the
- corresponding data in that node's parent. This retains the pruned
- node's color characteristics for later averaging.
- .PP
- For each node, \fIn\d\s-32\s0\u\fP pixels exist for which that node
- represents the smallest volume in RGB space containing those pixel's
- colors. When \fIn\d\s-32\s0\u > 0\fP the node will uniquely define a
- color in the output image. At the beginning of reduction,
- \fIn\d\s-32\s0\u = 0\fP for all nodes except the leaves of the tree
- which represent colors present in the input image.
- .PP
- The other pixel count, \fIn\d\s-31\s0\u\fP, indicates the total
- number of colors within the cubic volume which the node represents.
- This includes \fIn\d\s-31\s0\u - n\d\s-32\s0\u\fP pixels whose colors
- should be defined by nodes at a lower level in the tree.
- .PP
- \fBAssignment\fP generates the output image from the pruned tree. The
- output image consists of two parts: (1) A color map, which is an
- array of color descriptions (RGB triples) for each color present in the
- output image; (2) A pixel array, which represents each pixel as an
- index into the color map array.
- .PP
- First, the assignment phase makes one pass over the pruned color
- description tree to establish the image's color map. For each node
- with \fIn\d\s-32\s0\u > 0\fP, it divides \fIS\d\s-3r\s0\u,
- S\d\s-3g\s0\u\fP, and \fPS\d\s-3b\s0\u\fP by \fIn\d\s-32\s0\u\fP. This
- produces the mean color of all pixels that classify no lower than this
- node. Each of these colors becomes an entry in the color map.
- .PP
- Finally, the assignment phase reclassifies each pixel in the pruned
- tree to identify the deepest node containing the pixel's color. The
- pixel's value in the pixel array becomes the index of this node's mean
- color in the color map.
- .PP
- Empirical evidence suggests that distances in color spaces such as
- YUV, or YIQ correspond to perceptual color differences more closely
- than do distances in RGB space. These color spaces may give better
- results when color reducing an image. Here the algorithm is as described
- except each pixel is a point in the alternate color space. For convenience,
- the color components are normalized to the range 0 to a maximum value,
- \fIc\d\s-3max\s0\u\fP. The color reduction can then proceed as described.
- .SH "MEASURING COLOR REDUCTION ERROR"
- .PP
- Depending on the image, the color reduction error may be obvious or
- invisible. Images with high spatial frequencies (such as hair or
- grass) will show error much less than pictures with large smoothly
- shaded areas (such as faces). This is because the high-frequency
- contour edges introduced by the color reduction process are masked by
- the high frequencies in the image.
- .PP
- To measure the difference between the original and color reduced images
- (the total color reduction error), \fIImageMagick\fP sums over all pixels
- in an image the distance squared in RGB space between each original
- pixel value and its color reduced value. \fIImageMagick\fP prints several error
- measurements including the mean error per pixel, the normalized mean error,
- and the normalized maximum error.
- .PP
- The normalized error measurement can be used to compare images. In
- general, the closer the mean error is to zero the more the quantized
- image resembles the source image. Ideally, the error should be
- perceptually-based, since the human eye is the final judge of
- quantization quality.
- .PP
- These errors are measured and printed when \fB-verbose\fP and \fB-colors\fI
- are specified on the command line:
- .TP 5
- .B mean error per pixel:
- is the mean error for any single pixel in the image.
- .TP 5
- .B normalized mean square error:
- is the normalized mean square quantization error for any single pixel in the
- image.
- X
- This distance measure is normalized to a range between 0 and 1. It is
- independent of the range of red, green, and blue values in the image.
- .TP 5
- .B normalized maximum square error:
- is the largest normalized square quantization error for any single
- pixel in the image.
- X
- This distance measure is normalized to a range between 0 and 1. It is
- independent of the range of red, green, and blue values in the image.
- .SH SEE ALSO
- display(1), animate(1), mogrify(1), import(1), MIFF(5)
- .SH COPYRIGHT
- Copyright 1992 E. I. du Pont de Nemours & Company
- .PP
- Permission to use, copy, modify, distribute, and sell this software and
- its documentation for any purpose is hereby granted without fee,
- provided that the above copyright notice appear in all copies and that
- both that copyright notice and this permission notice appear in
- supporting documentation, and that the name of E. I. du Pont de Nemours
- & Company not be used in advertising or publicity pertaining to
- distribution of the software without specific, written prior
- permission. E. I. du Pont de Nemours & Company makes no representations
- about the suitability of this software for any purpose. It is provided
- "as is" without express or implied warranty.
- .PP
- E. I. du Pont de Nemours & Company disclaims all warranties with regard
- to this software, including all implied warranties of merchantability
- and fitness, in no event shall E. I. du Pont de Nemours & Company be
- liable for any special, indirect or consequential damages or any
- damages whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action, arising
- out of or in connection with the use or performance of this software.
- .SH ACKNOWLEDGEMENTS
- Paul Raveling, USC Information Sciences Institute, for the original
- idea of using space subdivision for the color reduction algorithm.
- With Paul's permission, this document is an adaptation from a document he
- wrote.
- .SH AUTHORS
- John Cristy, E.I. du Pont de Nemours & Company Incorporated
- SHAR_EOF
- chmod 0644 ImageMagick/quantize.man ||
- echo 'restore of ImageMagick/quantize.man failed'
- Wc_c="`wc -c < 'ImageMagick/quantize.man'`"
- test 11043 -eq "$Wc_c" ||
- echo 'ImageMagick/quantize.man: original size 11043, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= ImageMagick/compress.h ==============
- if test -f 'ImageMagick/compress.h' -a X"$1" != X"-c"; then
- echo 'x - skipping ImageMagick/compress.h (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting ImageMagick/compress.h (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/compress.h' &&
- /*
- X Compress utility routines.
- */
- extern unsigned int
- X HuffmanEncodeImage _Declare((Image *)),
- X LZWDecodeImage _Declare((Image *)),
- X LZWEncodeImage _Declare((Image *,unsigned int)),
- X QDecodeImage _Declare((unsigned char *,unsigned char *,unsigned int,
- X unsigned int)),
- X QEncodeImage _Declare((unsigned char *,unsigned char *,unsigned int,
- X unsigned int));
- SHAR_EOF
- chmod 0644 ImageMagick/compress.h ||
- echo 'restore of ImageMagick/compress.h failed'
- Wc_c="`wc -c < 'ImageMagick/compress.h'`"
- test 368 -eq "$Wc_c" ||
- echo 'ImageMagick/compress.h: original size 368, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= ImageMagick/XWDFile.h ==============
- if test -f 'ImageMagick/XWDFile.h' -a X"$1" != X"-c"; then
- echo 'x - skipping ImageMagick/XWDFile.h (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting ImageMagick/XWDFile.h (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/XWDFile.h' &&
- /* Copyright 1985, 1986, Massachusetts Institute of Technology */
- X
- /* $XConsortium: XWDFile.h,v 1.12 89/10/08 16:33:57 rws Exp $ */
- /*
- X * XWDFile.h MIT Project Athena, X Window system window raster
- X * image dumper, dump file format header file.
- X *
- X * Author: Tony Della Fera, DEC
- X * 27-Jun-85
- X *
- X * Modifier: William F. Wyatt, SAO
- X * 18-Nov-86 - version 6 for saving/restoring color maps
- X */
- X
- X
- /*
- X * This is not portable between machines of differing word sizes. To make
- X * it portable, do the following things:
- X *
- X * o #include <X11/Xmd.h>
- X * o remove the typedef for xwdval
- X * o replace all instances of xwdval with the appropriate CARD32 ... B32
- X * o make sure that XWDFileHeader is padded to quadword boundaries
- X * o make sure the window name is written out quadword aligned
- X * o create an XWDColor structure that contains the same fields as XColor
- X * but which is defined in terms of CARD32 B32, CARD16 B16, and CARD8
- X * o convert XColor structures to XWDColor structures in xwd
- X * o remove all xwdval casts from xwd
- X * o pack image data before writing out if necessary
- X * o replace casts from xwdval objects in xwud with cvtINT macros
- X * o convert XWDColor structures to XColor structures
- X * o unpack data after reading in if necessary
- X */
- X
- X
- #include <X11/Xmd.h>
- X
- #define XWD_FILE_VERSION 7
- #ifdef WORD64
- #define sz_XWDheader 104
- #else
- #define sz_XWDheader 100
- #endif
- #define sz_XWDColor 12
- X
- typedef CARD32 xwdval; /* for old broken programs */
- X
- typedef struct _xwd_file_header {
- X CARD32 header_size B32; /* Size of the entire file header (bytes). */
- X CARD32 file_version B32; /* XWD_FILE_VERSION */
- X CARD32 pixmap_format B32; /* Pixmap format */
- X CARD32 pixmap_depth B32; /* Pixmap depth */
- X CARD32 pixmap_width B32; /* Pixmap width */
- X CARD32 pixmap_height B32; /* Pixmap height */
- X CARD32 xoffset B32; /* Bitmap x offset */
- X CARD32 byte_order B32; /* MSBFirst, LSBFirst */
- X CARD32 bitmap_unit B32; /* Bitmap unit */
- X CARD32 bitmap_bit_order B32; /* MSBFirst, LSBFirst */
- X CARD32 bitmap_pad B32; /* Bitmap scanline pad */
- X CARD32 bits_per_pixel B32; /* Bits per pixel */
- X CARD32 bytes_per_line B32; /* Bytes per scanline */
- X CARD32 visual_class B32; /* Class of colormap */
- X CARD32 red_mask B32; /* Z red mask */
- X CARD32 green_mask B32; /* Z green mask */
- X CARD32 blue_mask B32; /* Z blue mask */
- X CARD32 bits_per_rgb B32; /* Log2 of distinct color values */
- X CARD32 colormap_entries B32; /* Number of entries in colormap */
- X CARD32 ncolors B32; /* Number of Color structures */
- X CARD32 window_width B32; /* Window width */
- X CARD32 window_height B32; /* Window height */
- X CARD32 window_x B32; /* Window upper left X coordinate */
- X CARD32 window_y B32; /* Window upper left Y coordinate */
- X CARD32 window_bdrwidth B32; /* Window border width */
- #ifdef WORD64
- X CARD32 header_end B32; /* Pad to fill out word */
- #endif
- } XWDFileHeader;
- X
- struct {
- X CARD32 pixel B32;
- X CARD16 red B16;
- X CARD16 green B16;
- X CARD16 blue B16;
- X CARD8 flags;
- X CARD8 pad;
- } XWDColor;
- SHAR_EOF
- chmod 0644 ImageMagick/XWDFile.h ||
- echo 'restore of ImageMagick/XWDFile.h failed'
- Wc_c="`wc -c < 'ImageMagick/XWDFile.h'`"
- test 3092 -eq "$Wc_c" ||
- echo 'ImageMagick/XWDFile.h: original size 3092, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= ImageMagick/alien.h ==============
- if test -f 'ImageMagick/alien.h' -a X"$1" != X"-c"; then
- echo 'x - skipping ImageMagick/alien.h (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting ImageMagick/alien.h (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/alien.h' &&
- X
- /*
- X Typedef declarations.
- */
- typedef struct _AlienInfo
- {
- X char
- X filename[2048];
- X
- X char
- X *server_name,
- X *font,
- X *geometry,
- X *density;
- X
- X unsigned int
- X verbose;
- } AlienInfo;
- X
- /*
- X Alien image format routines.
- */
- extern Image
- X *ReadAlienImage _Declare((AlienInfo *));
- X
- extern unsigned int
- X WriteAlienImage _Declare((Image *));
- X
- extern void
- X GetAlienInfo _Declare((AlienInfo *));
- SHAR_EOF
- chmod 0644 ImageMagick/alien.h ||
- echo 'restore of ImageMagick/alien.h failed'
- Wc_c="`wc -c < 'ImageMagick/alien.h'`"
- test 403 -eq "$Wc_c" ||
- echo 'ImageMagick/alien.h: original size 403, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= ImageMagick/SYNOPSIS ==============
- if test -f 'ImageMagick/SYNOPSIS' -a X"$1" != X"-c"; then
- echo 'x - skipping ImageMagick/SYNOPSIS (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting ImageMagick/SYNOPSIS (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/SYNOPSIS' &&
- ImageMagick is a collection of X11 image processing and display utilities. It
- is available on export.lcs.mit.edu as contrib/ImageMagick.tar.Z.
- X
- cristy@dupont.com
- X
- ---
- X
- Display
- X
- X Display is a machine architecture independent image
- X processing and display program. It can display an image on
- X any workstation display running an X server. Display first
- X determines the hardware capabilities of the workstation. If
- X the number of unique colors in the image is less than or
- X equal to the number the workstation can support, the image
- X is displayed in an X window. Otherwise the number of colors
- X in the image is first reduced to match the color resolution
- X of the workstation before it is displayed.
- X
- X This means that a continuous-tone 24 bits/pixel image can
- X display on a 8 bit pseudo-color device or monochrome device.
- X In most instances the reduced color image closely resembles
- X the original. Alternatively, a monochrome or pseudo-color
- X image can display on a continuous-tone 24 bits/pixels
- X device.
- X
- X
- Import
- X
- X Import reads an image from any visible window on an X server
- X and outputs it as an image file. You can capture a single
- X window, the entire screen, or any rectangular portion of the
- X screen. You can use display (see display(1)) utility for
- X redisplay, printing, editing, formatting, archiving, image
- X processing, etc. of the captured image.
- X
- X The target window can be specified by id, name, or may be
- X selected by clicking the mouse in the desired window. If
- X you press a button and then drag, a rectangle will form
- X which expands and contracts as the mouse moves. To save the
- X portion of the screen defined by the rectangle, just
- X release the button. The keyboard bell is rung once at the
- X beginning of the screen capture and twice when it completes.
- X
- X
- XXtoPS
- X
- X XtoPS reads an image from any visible window on an X server
- X and outputs it as Encapsulated Postscript. You can capture
- X a single window, the entire screen, or any rectangular
- X portion of the screen. You can view the captured screen
- X with any Postscript compatible viewer or printer. The
- X Postscript is displayed in color on viewers or printers that
- X support color, otherwise it is displayed as grayscale.
- X
- X The target window can be specified by id, name, or may be
- X selected by clicking the mouse in the desired window. If
- X you press a button and then drag, a rectangle will form
- X which expands and contracts as the mouse moves. To save the
- X portion of the screen defined by the rectangle, just release
- X the button. The keyboard bell is rung once at the beginning
- X of the screen capture and twice it completes.
- X
- X
- Animate
- X
- X Animate displays a sequence of images on any workstation
- X display running an X server. Animate first determines the
- X hardware capabilities of the workstation. If the number of
- X unique colors in an image is less than or equal to the
- X number the workstation can support, the image is displayed
- X in an X window. Otherwise the number of colors in the image
- X is first reduced to match the color resolution of the
- X workstation before it is displayed.
- X
- X This means that a continuous-tone 24 bits/pixel image can
- X display on a 8 bit pseudo-color device or monochrome device.
- X In most instances the reduced color image closely resembles
- X the original. Alternatively, a monochrome or pseudo-color
- X image sequence can display on a continuous-tone 24
- X bits/pixels device.
- X
- X
- Montage
- X
- X Montage creates a composite image by combining several
- X separate images. The images are tiled on the composite
- X image with the name of the image optionally appearing just
- X below the individual tile.
- X
- X
- Mogrify
- X
- X Mogrify transforms an image or a sequence of images. These
- X transforms include image scaling, image rotation, color
- X reduction, and others. The transmogrified image overwrites
- X the original image.
- X
- X
- Convert
- X
- X Convert converts an input file using one image format to an
- X output file with a differing image format. By default, the
- X image format is determined by it's magic number. To specify
- X a particular image format, precede the filename with an
- X image format name and a colon (i.e. mtv:image) or specify
- X the image type as the filename suffix (i.e. image.mtv).
- X Specify file as - for standard input or output. If file has
- X the extension .Z, the file is decoded with uncompress.
- X
- X Convert recognizes the following image formats:
- X
- X Tag Description
- X ----------------------------------------------------
- X AVS
- X CMYK Raw cyan, magenta, yellow, and black bytes
- X FAX Group 3
- X GIF
- X GRAY Raw gray bytes
- X JPEG
- X MIFF Machine Independant file format
- X MTV
- X PNM Portable bitmap
- X PS Postscript
- X RGB Raw red, green, and blue bytes
- X RLE Utah Raster Toolkit
- X SUN SUN raster
- X TEXT raw text file; read only
- X TIFF Tagged Image File Format
- X VICAR
- X X select image from X server screen; read only
- X XC constant image of X server background color
- X XBM X11 bitmap
- X XWD X11 window dump
- X
- XXTP
- X
- X Xtp is a utility for retrieving, listing, or printing files
- X from a remote network site, or sending files to a remote
- X network site. Xtp performs most of the same functions as
- X the ftp program, but does not require any interactive
- X commands. You simply specify the file transfer task on the
- X command line and xtp performs the task automatically.
- SHAR_EOF
- chmod 0644 ImageMagick/SYNOPSIS ||
- echo 'restore of ImageMagick/SYNOPSIS failed'
- Wc_c="`wc -c < 'ImageMagick/SYNOPSIS'`"
- test 5765 -eq "$Wc_c" ||
- echo 'ImageMagick/SYNOPSIS: original size 5765, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= ImageMagick/utilities/mogrify.c ==============
- if test ! -d 'ImageMagick/utilities'; then
- echo 'x - creating directory ImageMagick/utilities'
- mkdir 'ImageMagick/utilities'
- fi
- if test -f 'ImageMagick/utilities/mogrify.c' -a X"$1" != X"-c"; then
- echo 'x - skipping ImageMagick/utilities/mogrify.c (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting ImageMagick/utilities/mogrify.c (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/utilities/mogrify.c' &&
- /*
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % %
- % %
- % %
- % M M OOO GGGG RRRR IIIII FFFFF Y Y %
- % MM MM O O G R R I F Y Y %
- % M M M O O G GG RRRRR I FFF Y %
- % M M O O G G R R I F Y %
- % M M OOO GGG R R IIIII F Y %
- % %
- % %
- % Transmogrify an Image or Sequence of Images. %
- % %
- % %
- % %
- % Software Design %
- % John Cristy %
- % December 1992 %
- % %
- % %
- % Copyright 1992 E. I. du Pont de Nemours & Company %
- % %
- % Permission to use, copy, modify, distribute, and sell this software and %
- % its documentation for any purpose is hereby granted without fee, %
- % provided that the above Copyright notice appear in all copies and that %
- % both that Copyright notice and this permission notice appear in %
- % supporting documentation, and that the name of E. I. du Pont de Nemours %
- % & Company not be used in advertising or publicity pertaining to %
- % distribution of the software without specific, written prior %
- % permission. E. I. du Pont de Nemours & Company makes no representations %
- % about the suitability of this software for any purpose. It is provided %
- % "as is" without express or implied warranty. %
- % %
- % E. I. du Pont de Nemours & Company disclaims all warranties with regard %
- % to this software, including all implied warranties of merchantability %
- % and fitness, in no event shall E. I. du Pont de Nemours & Company be %
- % liable for any special, indirect or consequential damages or any %
- % damages whatsoever resulting from loss of use, data or profits, whether %
- % in an action of contract, negligence or other tortious action, arising %
- % out of or in connection with the use or performance of this software. %
- % %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %
- % `Mogrify' applies one or more image transforms to an image or sequence of
- % images and overwrites the original image.
- %
- % The Mogrify program command syntax is:
- %
- % Usage: mogrify [options ...] file [ [options ...] file ...]
- %
- % Where options include:
- % -clip geometry preferred size and location of the clipped image
- % -colormap filename transform image colors to match this set of colors
- % -colors value preferred number of colors in the image
- % -colorspace type GRAY, RGB, XYZ, YIQ, or YUV
- % -compress type RunlengthEncoded or QEncoded
- % -density geometry vertical and horizonal density of the image
- % -display server obtain image or font from this X server
- % -dither apply Floyd/Steinberg error diffusion to image
- % -enhance apply a digital filter to enhance a noisy image
- % -gamma value level of gamma correction
- % -geometry geometry preferred size of the image
- % -monochrome transform image to black and white
- % -noise reduce noise with a noise peak elimination filter
- % -normalize tranform image to span the full range of colors
- % -reflect reverse image scanlines
- % -rotate degrees apply Paeth rotation to the image
- % -scale geometry preferred size factors of the image
- % -scene value image scene number
- % -treedepth value depth of the color classification tree
- % -verbose print detailed information about the image
- %
- % Change '-' to '+' in any option above to reverse its effect. For
- % example, specify +compress to store the image as uncompressed.
- %
- % By default, the image format of `file' is determined by its magic
- % number. To specify a particular image format, precede the filename
- % with an image format name and a colon (i.e. mtv:image) or specify the
- % image type as the filename suffix (i.e. image.mtv). Specify 'file' as
- % '-' for standard input or output.
- %
- %
- */
- X
- /*
- X Include declarations.
- */
- #include "display.h"
- #include "image.h"
- #include "alien.h"
- #include "X.h"
- X
- /*
- X Global declarations.
- */
- char
- X *application_name;
- X
- /*
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % %
- % %
- % %
- % E r r o r %
- % %
- % %
- % %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %
- % Function Error displays an error message and then terminates the program.
- %
- % The format of the Error routine is:
- %
- % Error(message,qualifier)
- %
- % A description of each parameter follows:
- %
- % o message: Specifies the message to display before terminating the
- % program.
- %
- % o qualifier: Specifies any qualifier to the message.
- %
- %
- */
- void Error(message,qualifier)
- char
- X *message,
- X *qualifier;
- {
- X (void) fprintf(stderr,"%s: %s",application_name,message);
- X if (qualifier != (char *) NULL)
- X (void) fprintf(stderr," (%s)",qualifier);
- X (void) fprintf(stderr,".\n");
- X exit(1);
- }
- X
- /*
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % %
- % %
- % %
- % U s a g e %
- % %
- % %
- % %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %
- % Function Usage displays the program command syntax.
- %
- % The format of the Usage routine is:
- %
- % Usage()
- %
- %
- */
- static void Usage()
- {
- X char
- X **p;
- X
- X static char
- X *options[]=
- X {
- X "-clip geometry preferred size and location of the clipped image",
- X "-colormap filename transform image colors to match this set of colors",
- X "-colors value preferred number of colors in the image",
- X "-colorspace type GRAY, RGB, XYZ, YIQ, or YUV",
- X "-compress type RunlengthEncoded or QEncoded",
- X "-density geometry vertical and horizonal density of the image",
- X "-display server obtain image or font from this X server",
- X "-dither apply Floyd/Steinberg error diffusion to image",
- X "-enhance apply a digital filter to enhance a noisy image",
- X "-gamma value level of gamma correction",
- X "-geometry geometry preferred size of the image",
- X "-monochrome transform image to black and white",
- X "-noise reduce noise with a noise peak elimination filter",
- X "-normalize tranform image to span the full range of colors",
- X "-reflect reflect the image scanlines",
- X "-rotate degrees apply Paeth rotation to the image",
- X "-scale geometry preferred size factors of the image",
- X "-scene number image scene number",
- X "-treedepth value depth of the color classification tree",
- X "-verbose print detailed information about the image",
- X (char *) NULL
- X };
- X (void) fprintf(stderr,
- X "Usage: %s [-options ...] file [ [-options ...] file ...]\n",
- X application_name);
- X (void) fprintf(stderr,"\nWhere options include: \n");
- X for (p=options; *p != (char *) NULL; p++)
- X (void) fprintf(stderr," %s\n",*p);
- X (void) fprintf(stderr,
- X "\nChange '-' to '+' in any option above to reverse its effect. For\n");
- X (void) fprintf(stderr,
- X "example, specify +compress to store the image as uncompressed.\n");
- X (void) fprintf(stderr,
- X "\nBy default, the image format of `file' is determined by its magic\n");
- X (void) fprintf(stderr,
- X "number. To specify a particular image format, precede the filename\n");
- X (void) fprintf(stderr,
- X "with an image format name and a colon (i.e. mtv:image) or specify the\n");
- X (void) fprintf(stderr,
- X "image type as the filename suffix (i.e. image.mtv). Specify 'file' as\n");
- X (void) fprintf(stderr,"'-' for standard input or output.\n");
- X exit(1);
- }
- X
- /*
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % %
- % %
- % %
- % M a i n %
- % %
- % %
- % %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %
- %
- */
- int main(argc,argv)
- int
- X argc;
- X
- char
- X **argv;
- {
- X AlienInfo
- X alien_info;
- X
- X char
- X *clip_geometry,
- X *colormap_filename,
- X *image_geometry,
- X *option,
- X *scale_geometry;
- X
- X double
- X gamma;
- X
- X Image
- X **images;
- X
- X int
- X degrees,
- X i,
- X x;
- X
- X unsigned int
- X colorspace,
- X compression,
- X dither,
- X enhance,
- X image_number,
- X inverse,
- X maximum_images,
- X monochrome,
- X noise,
- X normalize,
- X number_colors,
- X reflect,
- X scene,
- X tree_depth,
- X verbose;
- X
- X /*
- X Display usage profile if there are no command line arguments.
- X */
- X application_name=(*argv);
- X if (argc < 2)
- X Usage();
- X /*
- X Set defaults.
- X */
- X GetAlienInfo(&alien_info);
- X clip_geometry=(char *) NULL;
- X colormap_filename=(char *) NULL;
- X colorspace=RGBColorspace;
- X compression=UndefinedCompression;
- X degrees=0;
- X dither=False;
- X enhance=False;
- X gamma=0.0;
- X image_geometry=(char *) NULL;
- X inverse=False;
- X monochrome=False;
- X noise=False;
- X normalize=False;
- X number_colors=0;
- X reflect=False;
- X scale_geometry=(char *) NULL;
- X scene=0;
- X tree_depth=0;
- X verbose=False;
- X maximum_images=2048;
- X images=(Image **) malloc(maximum_images*sizeof(Image *));
- X if (images == (Image **) NULL)
- X Error("unable to mogrify images","memory allocation failed");
- X /*
- X Parse command line.
- X */
- X image_number=0;
- X for (i=1; i < argc; i++)
- X {
- X option=argv[i];
- X if (((int) strlen(option) > 1) && ((*option == '-') || (*option == '+')))
- X switch (*(option+1))
- X {
- X case 'c':
- X {
- X if (strncmp("clip",option+1,2) == 0)
- X {
- X clip_geometry=(char *) NULL;
- X if (*option == '-')
- X {
- X i++;
- X if (i == argc)
- X Error("missing geometry on -clip",(char *) NULL);
- X clip_geometry=argv[i];
- X }
- X break;
- X }
- X if (strncmp("colormap",option+1,7) == 0)
- X {
- X colormap_filename=(char *) NULL;
- X if (*option == '-')
- X {
- X i++;
- X if (i == argc)
- X Error("missing file name on -colormap",(char *) NULL);
- X colormap_filename=argv[i];
- X }
- X break;
- X }
- X if (strncmp("colors",option+1,7) == 0)
- X {
- X number_colors=0;
- X if (*option == '-')
- X {
- X i++;
- X if ((i == argc) || !sscanf(argv[i],"%d",&x))
- X Error("missing colors on -colors",(char *) NULL);
- X number_colors=atoi(argv[i]);
- X }
- X break;
- X }
- X if (strncmp("colorspace",option+1,7) == 0)
- X {
- X colorspace=RGBColorspace;
- X if (*option == '-')
- X {
- X i++;
- X if (i == argc)
- X Error("missing type on -colorspace",(char *) NULL);
- X option=argv[i];
- X colorspace=UndefinedColorspace;
- X if (Latin1Compare("gray",option) == 0)
- X colorspace=GRAYColorspace;
- X if (Latin1Compare("rgb",option) == 0)
- X colorspace=RGBColorspace;
- SHAR_EOF
- true || echo 'restore of ImageMagick/utilities/mogrify.c failed'
- fi
- echo 'End of part 24'
- echo 'File ImageMagick/utilities/mogrify.c is continued in part 25'
- echo 25 > _shar_seq_.tmp
- exit 0
- exit 0 # Just in case...
-