Mogrify


Contents

Synopsis

mogrify [ options ...] file [ [ options ...] file ...]

Back to Contents


Description

mogrify transforms an image or a sequence of images. These transforms include image scaling, image rotation, color reduction, and others. The transmogrified image overwrites the original image.

Back to Contents


Examples

To convert all the TIFF files in a particular directory to JPEG, use:
    mogrify -format jpeg *.tiff
To scale an image of a cockatoo to exactly 640 pixels in width and 480 pixels in height, use:
    mogrify -geometry 640x480! cockatoo.miff
To create a single colormap for a sequence of bird images, use:
    mogrify -colors 256 scenes/birds.*

Back to Contents


Options

-annotate string
annotate an image with text.

Use this option to annotate an image with text. Optionally you can include the image filename, type, width, height, or scene number by embedding special format characters. Embed %f for filename, %m for magick, %w for width, %h for height, %s for scene number, or \n for newline. For example,
    -annotate "%m:%f %wx%h"
annotates the image with MIFF:bird.miff 512x480 for an image titled bird.miff and whose width is 512 and height is 480.

If the first character of string is @, the text is read from a file titled by the remaining characters in the string.

You can set the text position, font, font color, and bounding box color with -geometry, -font, -pen, and -box respectively. Options are processed in command line order so be sure to use -geometry, -font, -pen or -box before the -annotate option.

-blur factor
blurs an image. Specify factor as the percent enhancement (0.0 - 99.9%).

-border <width>x<height>
surround the image with a border or color. See X(1) for details about the geometry specification.

The color of the border is obtained from the X server and is defined as bordercolor (class borderColor). See X(1) for details.

-box color
set the color of the annotation bounding box. See -annotate for further details.

See \fBX(1)\fP for details about the color specification.

-colors value
preferred number of colors in the image.

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 quantize(9) for more details.

If more than one image is specified on the command line, a single colormap is created and saved with each image.

Note, options -colormap, -dither, -colorspace, and -treedepth affect the color reduction algorithm.

-colorspace value
the type of colorspace: GRAY, OHTA, RGB, XYZ, YCbCr, YIQ, YPbPr, or YUV.

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 quantize for more details.

The -colors or -monochrome option is required for this option to take effect.

-comment string
annotate an image with a comment.

By default, each image is commented with its file name. Use this option to assign a specific comment to the image. Optionally you can include the image filename, type, width, height, or scene number by embedding special format characters. Embed %f for filename, %m for magick, %w for width, %h for height, %s for scene number, or \n for newline. For example,
    -comment "%m:%f %wx%h"
produces an image comment of MIFF:bird.miff 512x480 for an image titled bird.miff and whose width is 512 and height is 480.

If the first character of string is @, the image comment is read from a file titled by the remaining characters in the string.

-compress type
the type of image compression: Zlib or RunlengthEncoded.

Specify +compress to store the binary image in an uncompressed format. The default is the compression type of the specified image file.

-contrast
enhance or reduce the image contrast.

This option enhances the intensity differences between the lighter and darker elements of the image. Use -contrast to enhance the image or +contrast to reduce the image contrast.

-crop <width>{%}x<height>{%}{+-}<x offset>{+-}<y offset>
preferred size and location of the cropped image. See X(1) for details about the geometry specification.

To specify a percentage width or height instead, append %. For example to crop the image by ten percent on all sides of the image, use -crop 10%.

Use cropping to apply image processing options, or transmogrify, only a particular area of an image. Use -crop 0x0 to remove edges that are the background color.

-density <width>x<height>
vertical and horizontal resolution in pixels of the image.

This option specifies an image density when decoding a Postscript or Portable Document page. The default is 72 pixels per inch in the horizontal and vertical direction.

-despeckle
reduce the speckles within an image.

-display host:display[.screen] specifies the X server to contact; see X(1).

-dither
apply Floyd/Steinberg error diffusion to the image.

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.

The -colors or -monochrome option is required for this option to take effect.

-draw string
annotate an image with graphic primitives.

Use this option to annotate an image with one or more graphic primitives. The primitives include

  rectangle
  circle
  polygon

A rectangle primitive requires an upper left and lower right coordinate. The circle requires the center coordinate and a coordinate on the outer edge. Finally, the polygon primitive requires three or more coordinates defining its boundaries. Coordinates are integers separated by an optional comma. For example, to define a circle centered at 100,100 that extends to 150,150 use:

  -draw "circle 100,100 150,150"

If the first character of string is @, the text is read from a file titled by the remaining characters in the string.

You can set the primitive color with -pen. Options are processed in command line order so be sure to use -pen before the -draw option.

-edge
detect edges within an image.

-emboss
emboss the image.

-enhance
apply a digital filter to enhance a noisy image.

-equalize
perform histogram equalization to the image.

-flip
create a "mirror image" by reflecting the image scanlines in the vertical direction.

-flop
create a "mirror image" by reflecting the image scanlines in the horizontal direction.

-format type
the image format type.

This option will convert any image to the image format you specify. See convert(1) for a list of image format types supported by ImageMagick.

By default the file is written to its original name. However, if the filename extension matches a supported format, the extension is replaced with the image format type specified with -format. For example, if you specify tiff as the format type and the input image filename is image.gif, the output image filename becomes image.tiff.

-font name
use this font when annotating the image with text.

Convert contacts an X server to obtain the font. If an X server is not available, a Postscript font is used instead. You can set the pointsize with -pointsize.

-frame <width>x<height>+<outer bevel width>+<inner bevel width>
surround the image with an an ornamental border. See X(1) for details about the geometry specification.

The color of the border is specified with the -mattecolor command line option.

-gamma value
level of gamma correction.

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.

You can apply separate gamma values to the red, green, and blue channels of the image with a gamma value list delineated with commas (i.e. 1.7,2.3,1.2).

-geometry <width>{%}x<height>{%}{!}{<}{>}
preferred width and height of the image. See X(1) for details about the geometry specification.

By default, the width and height are maximum values. That is, the image is expanded or contracted to fit the width and height value while maintaining the aspect ratio of the image. Append an exclamation point to the geometry to force the image size to exactly the size you specify. For example, if you specify 640x480! the image width is set to 640 pixels and height to 480. If only one factor is specified, both the width and height assume the value.

To specify a percentage width or height instead, append %. The image size is multiplied by the width and height percentages to obtain the final image dimensions. To increase the size of an image, use a value greater than 100 (e.g. 125%). To decrease an image's size, use a percentage less than 100.

Use < to change the dimensions of the image only if its size exceeds the geometry specification. > resizes the image only if its dimensions is less than the geometry specification. For example, if you specify 640x480> and the image size is 512x512, the image size does not change. However, if the image is 1024x1024, it is resized to 640x480.

-interlace type
the type of interlacing scheme: NONE, LINE, or PLANE.

This option is used to specify the type of interlacing scheme for raw image formats such as RGB or YUV. NONE means do not interlace (RGBRGBRGBRGBRGBRGB...), LINE uses scanline interlacing (RRR...GGG...BBB...RRR...GGG...BBB...), and PLANE uses plane interlacing (RRRRRR...GGGGGG...BBBBBB...).

Use LINE, or PLANE to create an interlaced GIF or progressive JPEG image.

-label name assign a label to an image.

Use this option to assign a specific label to the image. Optionally you can include the image filename, type, width, height, or scene number in the label by embedding special format characters. Embed %f for filename, %m for magick, %w for width, %h for height, or %s for scene number, or \n for newline For example,
    -label "%m:%f %wx%h"
produces an image label of MIFF:bird.miff 512x480 for an image titled bird.miff and whose width is 512 and height is 480.

If the first character of string is @, the image label is read from a file titled by the remaining characters in the string.

When converting to Postscript, use this option to specify a header string to print above the image.

-map filename
choose a particular set of colors from this image.

By default, color reduction chooses an optimal set of colors that best represent the original image. Alternatively, you can choose a particular set of colors with this option. This is useful when you want to create a sequence of images with one particular set of colors for each image.

-modulate value
vary the brightness, saturation, and hue of an image.

Specify the percent change in brightness, the color saturation, and the hue separated by commas. For example, to increase the color brightness by 20% and decrease the color saturation by 10% and leave the hue unchanged, use: -modulate 20,-10.

-monochrome
transform the image to black and white.

-negate
apply color inversion to image.

The red, green, and blue intensities of an image are negated.

-noise
reduce the noise in an image with a noise peak elimination filter.

The principal function of noise peak elimination filter is to smooth the objects within an image without losing edge information and without creating undesired structures. The central idea of the algorithm is to replace a pixel with its next neighbor in value within a 3 x 3 window, if this pixel has been found to be noise. A pixel is defined as noise if and only if this pixel is a maximum or minimum within the 3 x 3 window.

-normalize
transform image to span the full range of color values. This is a contrast enhancement technique.

-opaque color
change this color to the pen color within the image. See -pen for more details.

-page <width>x<height>{+-}<x offset>{+-}<y offset>
preferred size and location of the Postscript page.

Use this option to specify the dimensions of the Postscript page in pixels per inch or a TEXT page in pixels. The default for a Postscript page is to center the image on a letter page 612 by 792 pixels. The margins are 1/2" (i.e. 723x935+42+42). Other common sizes are:
    Letter      612x 792
    Tabloid     792x1224
    Ledger     1224x 792
    Legal       612x1008
    Statement   396x 612
    Executive   540x 720
    A3          842x1190
    A4          595x 842
    A5          420x 595
    B4          729x1032
    B5          516x 729
    Folio       612x 936
    Quarto      610x 780
    10x14       720x1008
For convenience you can specify the page size by media (e.g. A4, Ledger, etc.).

The page geometry is relative to the vertical and horizontal density of the Postscript page. See -density for details.

The default page dimensions for a TEXT image is 723x935.

-paint
paint the image.

-pen color
set the color of the font or opaque color. See -annotate or -opaque for further details.

See X(1) for details about the color specification.

-pointsize value
pointsize of the Postscript font.

-quality value
JPEG quality setting.

Quality is 0 (worst) to 100 (best). The default is 72.

-raise <bevel width>
lighten or darken image edges to create a 3-D effect.

Bevel width is the width of an edge. Use -raise to create a raised effect, otherwise use +raise.

-roll {+-}<x offset>{+-}<y offset>
roll an image vertically or horizontally. See X(1) for details about the geometry specification.

A negative x offset rolls the image left-to-right. A negative y offset rolls the image top-to-bottom.

-rotate degrees
apply Paeth image rotation to the image.

Empty triangles left over from rotating the image are filled with the color defined as bordercolor (class borderColor). See X(1) for details.

-sample geometry
scale image with pixel sampling. See -geometry for details about the geometry specification.

-scene value
image scene number.

-segment value
eliminate clusters that are insignificant.

The number of pixels in each cluster must exceed the the cluster threshold to be considered valid.

-sharpen weight
sharpen an image. Specify factor as the percent enhancement (0.0 - 99.9%).

-shear <x degrees>x<y degrees>
shear the image along the X or Y axis by a positive or negative shear angle.

Shearing slides one edge of an image along the X or Y axis, creating a parallelogram. An X direction shear slides an edge along the X axis, while a Y direction shear slides an edge along the Y axis. The amount of the shear is controlled by a shear angle. For X direction shears, x degrees> is measured relative to the Y axis, and similarly, for Y direction shears y degrees is measured relative to the X axis.

Empty triangles left over from shearing the image are filled with the color defined as bordercolor (class borderColor). See X(1) for details.

-size <width>{%}x<height>{%}{+offset}{!}
width and height of the image.

Use this option to specify the width and height of raw images whose dimensions are unknown such as GRAY, RGB, or CMYK. In addition to width and height, use -size to skip any header information in the image or tell the number of colors in a MAP image file, (e.g. -size 640x512+256).

-texture filename
name of texture to tile onto the image background.

-transparency color
make this color transparent within the image.

-treedepth value
Normally, this integer value is zero or one. A zero or one tells mogrify to choose a optimal tree depth for the color reduction algorithm.

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 quantize for more details.

The -colors or -monochrome option is required for this option to take effect.

-undercolor <undercolor factor>x<black-generation factor>
control undercolor removal and black generation on CMYK images.

This option enables you to perform undercolor removal and black generation on CMYK images-- images to be printed on a four-color printing system. You can control how much cyan, magenta, and yellow to remove from your image and how much black to add to it. The standard undercolor removal is 1.0x1.0. You'll frequently get better results, though, if the percentage of black you add to your image is slightly higher than the percentage of C, M, and Y you remove from it. For example you might try 0.5x0.7.

-verbose
print detailed information about the image.

This information is printed: image scene number; image name; image size; the image class (DirectClass or PseudoClass); the total number of unique colors (if known); and the number of seconds to read and transform the image. Refer to miff(5) for a description of the image class. If -colors is also specified, the total unique colors in the image and color reduction error values are printed. Refer to quantize(9) for a description of these values.

Options are processed in command line order. 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 mogrify two images, the first with 32 colors and the second with only 16 colors, use:
    mogrify -colors 32 cockatoo.miff -colors 16 macaw.miff
Change - to + in any option above to reverse its effect. For example, specify +compress to store the binary image in an uncompressed format.

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. ps:image) or specify the image type as the filename suffix (i.e. image.ps). See convert(1) for a list of valid image formats.

Specify file as - for standard input and output. If file has the extension .Z or .gz, the file is uncompressed with uncompress or gunzip respectively and subsequently compressed using with compress or gzip. Finally, precede the image file name with | to pipe to or from a system command.

Use an optional index enclosed in brackets after a file name to specify a desired subimage of a multi-resolution image format like Photo CD (e.g. img0001.pcd[4]) or a range for MPEG images (e.g. video.mpg[50-75]).

Back to Contents


Image Segmentation

Use -segment to segment an image by analyzing the histograms of the color components and identifying units that are homogeneous with the fuzzy c-means technique. The scale-space filter analyzes the histograms of the three color components of the image and identifies a set of classes. The extents of each class is used to coarsely segment the image with thresholding. The color associated with each class is determined by the mean color of all pixels within the extents of a particular class. Finally, any unclassified pixels are assigned to the closest class with the fuzzy c-means technique.

The fuzzy c-Means algorithm can be summarized as follows:

The fuzzy c-Means technique attempts to cluster a pixel by finding the local minima of the generalized within group sum of squared error objective function. A pixel is assigned to the closest class of which the fuzzy membership has a maximum value.

For additional information see:

Young Won Lim, Sang Uk Lee, "On The Color Image Segmentation Algorithm Based on the Thresholding and the Fuzzy c-Means Techniques", Pattern Recognition, Volume 23, Number 9, pages 935-952, 1990.

Back to Contents


Copyright

Copyright 1995 E. I. du Pont de Nemours and 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 and 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 and 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 and 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 and 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 tortuous action, arising out of or in connection with the use or performance of this software.

Back to Contents


Acknowledgements

The MIT X Consortium for making network transparent graphics a reality.

Michael Halle, Spatial Imaging Group at MIT, for the initial implementation of Alan Paeth's image rotation algorithm.

David Pensak, E. I. du Pont de Nemours and Company, for providing a computing environment that made this program possible.

Paul Raveling, USC Information Sciences Institute. The spacial subdivision color reduction algorithm is based on his Img software.

Back to Contents


Authors

John Cristy, cristy@dupont.com E.I. du Pont de Nemours and Company Incorporated.

Back to Contents


[home page]