- NAME
- SYNOPSIS
- FUNCTION DESCRIPTIONS

- AccessDefinition
- AddDefinitions
- AllocateImage
- AllocateImageColormap
- AllocateNextImage
- AnimateImages
- AppendImages
- AverageImages
- CatchImageException
- ChannelImage
- ClipPathImage
- CloneImage
- CloneImageInfo
- CycleColormapImage
- DescribeImage
- DestroyImage
- DestroyImageInfo
- DisplayImages
- GetImageChannelDepth
- GetImageDepth
- GetImageException
- GetImageGeometry
- GetImageInfo
- GetImageStatistics
- GetImageType
- GrayscalePseudoClassImage
- IsImagesEqual
- IsTaintImage
- ModifyImage
- PlasmaImage
- QuantumOperatorImage
- QuantumOperatorRegionImage
- ReferenceImage
- RemoveDefinitions
- SetImage
- SetImageChannelDepth
- SetImageClipMask
- SetImageDepth
- SetImageOpacity
- SetImageType
- TextureImage

# NAME

image - Miscellaneous image methods

# SYNOPSIS

const char * AccessDefinition( const ImageInfo *image_info, const char *magick, const char *key );

void AddDefinitions( ImageInfo *image_info, const char *options );

Image * AllocateImage( const ImageInfo *image_info );

unsigned int AllocateImageColormap( Image *image, const unsigned long colors );

void AllocateNextImage( const ImageInfo *image_info, Image *image );

unsigned int AnimateImages( const ImageInfo *image_info, Image *image );

Image * AppendImages( const Image *image, const unsigned int stack, ExceptionInfo *exception );

Image * AverageImages( Image *image, ExceptionInfo *exception );

ExceptionType CatchImageException( Image *image );

unsigned int ChannelImage( Image *image, const ChannelType channel );

unsigned int ClipPathImage( Image *image, const char *pathname, const unsigned int inside );

Image * CloneImage( const Image *image, const unsigned long columns, const unsigned long rows, const unsigned int orphan, ExceptionInfo *exception );

ImageInfo * CloneImageInfo( const ImageInfo *image_info );

CycleColormapImage( Image *image, const int amount );

void DescribeImage( Image *image, FILE *file, const unsigned int verbose );

void DestroyImage( Image *image );

void DestroyImageInfo( ImageInfo *image_info );

unsigned int DisplayImages( const ImageInfo *image_info, Image *image );

unsigned long GetImageChannelDepth( const Image *image, const ChannelType channel, ExceptionInfo *exception );

unsigned long GetImageDepth( const Image *image, ExceptionInfo *exception );

void GetImageException( Image *image, ExceptionInfo *exception );

int GetImageGeometry( const Image *image, const char *geometry, const unsigned int size_to_fit, RectangleInfo *region_info );

void GetImageInfo( ImageInfo *image_info );

MagickPassFail GetImageStatistics( const Image *image, ImageStatistics *statistics ExceptionInfo *exception );

ImageType GetImageType( const Image *image, ExceptionInfo *exception );

void GrayscalePseudoClassImage( Image *image );

unsigned int IsImagesEqual( Image *image, const Image *reference );

unsigned int IsTaintImage( const Image *image );

ModifyImage( Image *image, ExceptionInfo *exception );

unsigned int PlasmaImage( Image *image, const SegmentInfo *segment, unsigned long attenuate, unsigned long depth );

MagickPassFail QuantumOperatorImage( Image *image, ChannelType channel, QuantumOperator operator, double rvalue );

MagickPassFail QuantumOperatorRegionImage( Image *image, long x, long y, unsigned long columns, unsigned long rows, ChannelType channel, QuantumOperator quantum_operator, double rvalue );

Image * ReferenceImage( Image *image );

void RemoveDefinitions( ImageInfo *image_info, const char *options );

void SetImage( Image *image, const Quantum opacity );

unsigned int SetImageClipMask( Image *image, Image *clip_mask );

unsigned int SetImageDepth( Image *image, const unsigned long depth );

void SetImageOpacity( Image *image, const unsigned int opacity );

SetImageType( Image *image, const ImageType image_type );

unsigned int TextureImage( Image *image, const Image *texture );

# FUNCTION DESCRIPTIONS

## AccessDefinition

> AccessDefinition() searches the definitions for an entry matching the specified magick and key. NULL is returned if no matching entry is found.

The format of the AccessDefinition method is:

> const char *AccessDefinition ( const ImageInfo *image_info, const char *magick, const char *key );

A description of each parameter follows:

image_info:

  The image info.

magick:

  Format ID. This is usually the same as the coder name.

key:

  Key to search for.

## AddDefinitions

> AddDefinitions() adds definitions from a key/value based string to the current map of definitions in ImageInfo. Definitions may be used by coders/decoders that read and write images.

The format of the AddDefinitions method is:

> void AddDefinitions ( ImageInfo *image_info, const char *options );

A description of each parameter follows:

image_info:

  The image info.

options:

  List of key/value pairs to put in the definitions map. The format of the string is ``key1[=[value1]],key2[=[value2]],...''. A missing value argument (with or without the equal sign) inserts an empty, zero length string as value for a key.

exception:

  Errors result in updates to this structure.

## AllocateImage

> AllocateImage() returns a pointer to an image structure initialized to default values.

The format of the AllocateImage method is:

> Image *AllocateImage ( const ImageInfo *image_info );

A description of each parameter follows:

image_info:

  Many of the image default values are set from this structure. For example, filename, compression, depth, background color, and others.

## AllocateImageColormap

> AllocateImageColormap() allocates an image colormap and initializes it to a linear gray colorspace with increasing intensity. If the image already has a colormap, it is replaced. AllocateImageColormap ( ) returns True if successful, otherwise False if there is not enough memory.

The format of the AllocateImageColormap method is:

> unsigned int AllocateImageColormap ( Image *image, const unsigned long colors );

A description of each parameter follows:

image:

  The image.

colors:

  The number of colors in the image colormap.

## AllocateNextImage

> Use AllocateNextImage() to initialize the next image in a sequence to default values. The next member of image points to the newly allocated image. If there is a memory shortage, next is assigned NULL.

The format of the AllocateNextImage method is:

> void AllocateNextImage ( const ImageInfo *image_info, Image *image );

A description of each parameter follows:

image_info:

  Many of the image default values are set from this structure. For example, filename, compression, depth, background color, and others.

image:

  The image.

## AnimateImages

> AnimateImages() repeatedly displays an image sequence to any X window screen. It returns a value other than 0 if successful. Check the exception member of image to determine the reason for any failure.

The format of the AnimateImages method is:

> unsigned int AnimateImages ( const ImageInfo *image_info, Image *image );

A description of each parameter follows:

image_info:

  The image info.

image:

  The image.

## AppendImages

> The AppendImages() method takes a set of images and appends them to each other top-to-bottom if the stack parameter is true, otherwise left-to-right.

The format of the AppendImage method is:

> Image *AppendImages ( const Image *image, const unsigned int stack, ExceptionInfo *exception );

A description of each parameter follows:

image:

  The image sequence.

stack:

  A value other than 0 stacks the images top-to-bottom.

exception:

  Return any errors or warnings in this structure.

## AverageImages

The `Average()` method takes a set of images and averages them together. Each image in the set must have the same width and height. `Average()` returns a single image with each corresponding pixel component of each image averaged. On failure, a NULL image is returned and exception describes the reason for the failure.

The format of the AverageImage method is:

> Image *AverageImages ( Image *image, ExceptionInfo *exception );

A description of each parameter follows:

image:

  The image sequence.

exception:

  Return any errors or warnings in this structure.

## CatchImageException

> CatchImageException() returns if no exceptions are found in the image sequence, otherwise it determines the most severe exception and reports it as a warning or error depending on the severity.

The format of the CatchImageException method is:

> ExceptionType CatchImageException ( Image *image );

A description of each parameter follows:

image:

  An image sequence.

## ChannelImage

Transform an image so that the resulting image is a grayscale image based on a specified image channel. The resulting image is returned in the RGB colorspace. This function does not force or assume an input image colorspace so it may be used to extract channels from images in colorspaces other than RGB or CMYK. For example, if the image is currently transformed to the HWB colorspace, the 'B' channel may be extracted by specifying RedChannel as the ChannelType argument.

The format of the ChannelImage method is:

> unsigned int ChannelImage ( Image *image, const ChannelType channel );

A description of each parameter follows:

image:

  The image.

channel:

  Identify which channel to extract: Red, Cyan, Green, Magenta, Blue, Yellow, or Opacity.

## ClipPathImage

> ClipPathImage() sets the image clip mask based any clipping path information if it exists.

The format of the ClipPathImage method is:

> unsigned int ClipPathImage ( Image *image, const char *pathname, const unsigned int inside );

A description of each parameter follows:

image:

  The image.

pathname:

  name of clipping path resource. If name is preceded by #, use clipping path numbered by name.

inside:

  if non-zero, later operations take effect inside clipping path. Otherwise later operations take effect outside clipping path.

## CloneImage

> CloneImage() copies an image and returns the copy as a new image object. If the specified columns and rows is 0, an exact copy of the image is returned, otherwise the pixel data is undefined and must be initialized with the SetImagePixels ( ) and SyncImagePixels ( ) methods. On failure, a NULL image is returned and exception describes the reason for the failure.

The format of the CloneImage method is:

> Image *CloneImage ( const Image *image, const unsigned long columns, const unsigned long rows, const unsigned int orphan, ExceptionInfo *exception );

A description of each parameter follows:

image:

  The image.

columns:

  The number of columns in the cloned image.

rows:

  The number of rows in the cloned image.

orphan:

  With a value other than 0, the cloned image is an orphan. An orphan is a stand-alone image that is not assocated with an image list. In effect, the next and previous members of the cloned image is set to NULL.

exception:

  Return any errors or warnings in this structure.

## CloneImageInfo

> CloneImageInfo() makes a copy of the given image info structure. If NULL is specified, a new image info structure is created initialized to default values.

The format of the CloneImageInfo method is:

> ImageInfo *CloneImageInfo ( const ImageInfo *image_info );

A description of each parameter follows:

image_info:

  The image info.

## CycleColormapImage

`CycleColormap()` displaces an image's colormap by a given number of positions. If you cycle the colormap a number of times you can produce a psychodelic effect.

The format of the CycleColormapImage method is:

> CycleColormapImage ( Image *image, const int amount );

A description of each parameter follows:

image:

  The image.

amount:

  Offset the colormap this much.

## DescribeImage

> DescribeImage() describes an image by printing its attributes to the file. Attributes include the image width, height, size, and others.

The format of the DescribeImage method is:

> void DescribeImage ( Image *image, FILE *file, const unsigned int verbose );

A description of each parameter follows:

image:

  The image.

file:

  The file, typically stdout.

verbose:

  A value other than zero prints more detailed information about the image.

## DestroyImage

> DestroyImage() dereferences an image, deallocating memory associated with the image if the reference count becomes zero.

The format of the DestroyImage method is:

> void DestroyImage ( Image *image );

A description of each parameter follows:

image:

  The image.

## DestroyImageInfo

> DestroyImageInfo() deallocates memory associated with a ImageInfo structure.

The format of the DestroyImageInfo method is:

> void DestroyImageInfo ( ImageInfo *image_info );

A description of each parameter follows:

image_info:

  The image info.

## DisplayImages

> DisplayImages() displays an image sequence to any X window screen. It returns a value other than 0 if successful. Check the exception member of image to determine the reason for any failure.

The format of the DisplayImages method is:

> unsigned int DisplayImages ( const ImageInfo *image_info, Image *image );

A description of each parameter follows:

image_info:

  The image info.

image:

  The image.

## GetImageChannelDepth

> GetImageChannelDepth() returns the minimum bit depth required to store the specified image channel without actual loss of color resolution. Pixel components are stored in a Quantum, which is 8, 16, or 32 bits depending on the QuantumDepth value set when the software is compiled. GetImageChannelDepth ( ) returns the smallest modulus storage size which supports the scale of the pixel within the range ( i.e. no information is lost ) . As an example, the value one is returned for a bilevel channel since only one bit of resolution is required to represent a bilevel channel.

The format of the GetImageChannelDepth method is:

> unsigned long GetImageChannelDepth ( const Image *image, const ChannelType channel, ExceptionInfo *exception );

A description of each parameter follows:

image:

  The image.

channel:

  Channel to test.

exception:

  Return any errors or warnings in this structure.

## GetImageDepth

> GetImageDepth() returns the minimum bit depth of the image required to ensure that data is not lost in the red, green, blue, and opacity, channels. Pixel components are stored in a Quantum, which is 8, 16, or 32 bits depending on the QuantumDepth value set when the software is compiled. GetImageDepth ( ) returns the smallest modulus storage size which supports the scale of the pixel within the range ( i.e. no information is lost ) . As an example, the value one is returned for a black and white image since only one bit of resolution is required to represent a black and white image.

The format of the GetImageDepth method is:

> unsigned long GetImageDepth ( const Image *image, ExceptionInfo *exception );

A description of each parameter follows:

image:

  The image.

exception:

  Return any errors or warnings in this structure.

## GetImageException

> GetImageException() traverses an image sequence and returns any error more severe than noted by the exception parameter.

The format of the GetImageException method is:

> void GetImageException ( Image *image, ExceptionInfo *exception );

A description of each parameter follows:

image:

  Specifies a pointer to a list of one or more images.

exception:

  return the highest severity exception.

## GetImageGeometry

> GetImageGeometry() returns a region as defined by the geometry string with respect to the image and its gravity.

The format of the GetImageGeometry method is:

> int GetImageGeometry ( const Image *image, const char *geometry, const unsigned int size_to_fit, RectangleInfo *region_info );

A description of each parameter follows:

flags:

  Method GetImageGeometry returns a bitmask that indicates which of the four values were located in the geometry string.

geometry:

  The geometry (e.g. 100x100+10+10).

size_to_fit:

  A value other than 0 means to scale the region so it fits within the specified width and height.

region_info:

  The region as defined by the geometry string with respect to the image and its gravity.

## GetImageInfo

> GetImageInfo() initializes image_info to default values.

The format of the GetImageInfo method is:

> void GetImageInfo ( ImageInfo *image_info );

A description of each parameter follows:

image_info:

  The image info.

## GetImageStatistics

GetImageStatistics computes common statistics (currently maximum, minimum, mean and standard deviation) for the available image channels. The per-channel values are returned in an ImageStatistics structure. Statistics are normalized to the range 0.0 to 1.0. Multiply values by MaxRGB to obtain the statistics in quantum units. Statistics for non-existent channels are set to zero.

The format of the GetImageStatistics method is:

> MagickPassFail GetImageStatistics ( const Image *image, ImageStatistics *statistics ExceptionInfo *exception );

A description of each parameter follows:

image:

  The image.

statistics:

  An ImageStatistics structure to update with statistics.

exception:

  Any errors are reported here.

## GetImageType

> GetImageType() returns the type of image:

          Bilevel        Grayscale       GrayscaleMatte
          Palette        PaletteMatte    TrueColor
          TrueColorMatte ColorSeparation ColorSeparationMatte

The format of the GetImageType method is:

> ImageType GetImageType ( const Image *image, ExceptionInfo *exception );

A description of each parameter follows:

image:

  The image.

exception:

  Return any errors or warnings in this structure.

## GrayscalePseudoClassImage

GrayscalePseudoClassImage converts an image to a PseudoClass grayscale representation with an (optionally) compressed and sorted colormap. Colormap is ordered by increasing intensity.

The format of the GrayscalePseudoClassImage method is:

> void GrayscalePseudoClassImage ( Image *image );

A description of each parameter follows:

image:

  The image.

optimize_colormap:

  If true, produce an optimimal (compact) colormap.

## IsImagesEqual

> IsImagesEqual() measures the difference between colors at each pixel location of two images. A value other than 0 means the colors match exactly. Otherwise an error measure is computed by summing over all pixels in an image the distance squared in RGB space between each image pixel and its corresponding pixel in the reference image. The error measure is assigned to these image members:

mean_error_per_pixel:

  The mean error for any single pixel in the image.

normalized_mean_error:

  The normalized mean quantization error for any single pixel in the image. 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.

normalized_maximum_error:

  The normalized maximum quantization error for any single pixel in the image. 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 your image.

A small normalized mean square error, accessed as image->normalized_mean_error, suggests the images are very similiar in spatial layout and color.

The format of the IsImagesEqual method is:

> unsigned int IsImagesEqual ( Image *image, const Image *reference );

A description of each parameter follows.

image:

  The image.

reference:

  The reference image.

## IsTaintImage

> IsTaintImage() returns a value other than 0 if any pixel in the image has been altered since it was first constituted.

The format of the IsTaintImage method is:

> unsigned int IsTaintImage ( const Image *image );

A description of each parameter follows:

image:

  The image.

## ModifyImage

> ModifyImage() ensures that there is only a single reference to the image to be modified, updating the provided image pointer to point to a clone of the original image if necessary.

The format of the ModifyImage method is:

> ModifyImage ( Image *image, ExceptionInfo *exception );

A description of each parameter follows:

image:

  The image.

exception:

  Return any errors or warnings in this structure.

## PlasmaImage

> PlasmaImage() initializes an image with plasma fractal values. The image must be initialized with a base color and the random number generator seeded before this method is called.

The format of the PlasmaImage method is:

> unsigned int PlasmaImage ( Image *image, const SegmentInfo *segment, unsigned long attenuate, unsigned long depth );

A description of each parameter follows:

image:

  The image.

segment:

  Define the region to apply plasma fractals values.

attenuate:

  Define the plasma attenuation factor.

depth:

  Limit the plasma recursion depth.

## QuantumOperatorImage

> QuantumOperatorImage() performs the requested integer arithmetic operation on the selected channels of the image.

The format of the QuantumOperatorImage method is:

> MagickPassFail QuantumOperatorImage ( Image *image, ChannelType channel, QuantumOperator operator, double rvalue );

A description of each parameter follows:

image:

  The image.

channel:

  Channel to operate on.

quantum_operator:

  arithmetic or bitwise operator to use (AddQuantumOp, AndQuantumOp, DivideQuantumOp, LShiftQuantumOp, MultiplyQuantumOp, OrQuantumOp, RShiftQuantumOp, SubtractQuantumOp, XorQuantumOp).

rvalue:

  Operator argument.

exception:

  Updated with error description.

## QuantumOperatorRegionImage

> QuantumOperatorRegionImage() performs the requested integer arithmetic operation on the selected channels of the image over the specified region.

The format of the QuantumOperatorRegionImage method is:

> MagickPassFail QuantumOperatorRegionImage ( Image *image, long x, long y, unsigned long columns, unsigned long rows, ChannelType channel, QuantumOperator quantum_operator, double rvalue );

A description of each parameter follows:

image:

  The image.

channel:

  Channel to operate on.

x:

  Ordinate of left row of region.

y:

  Orginate of top column of region.

columns:

  Width of region.

rows:

  Height of region.

quantum_operator:

  arithmetic or bitwise operator to use (AddQuantumOp, AndQuantumOp, DivideQuantumOp, LShiftQuantumOp, MultiplyQuantumOp, OrQuantumOp, RShiftQuantumOp, SubtractQuantumOp, XorQuantumOp).

rvalue:

  Operator argument.

exception:

  Updated with error description.

## ReferenceImage

> ReferenceImage() increments the reference count associated with an image returning a pointer to the image.

The format of the ReferenceImage method is:

> Image *ReferenceImage ( Image *image );

A description of each parameter follows:

image:

  The image.

## RemoveDefinitions

> RemoveDefinitions() removes definitions from the current map of definitions in ImageInfo. Definitions may be used by coders/decoders that read and write images. RemoveDefinitions ( ) returns true only if the specified keys are present in the map and are actually removed.

The format of the RemoveDefinitions method is:

> void RemoveDefinitions ( ImageInfo *image_info, const char *options );

A description of each parameter follows:

image_info:

  The image info.

keys:

  List of keys to remove from the definitions map. The format of the string is ``key1,key2,...''. A special key, *, removes all the key/value pairs in the definitions map. This key always succeeds.

exception:

  Errors result in updates to this structure.

## SetImage

> SetImage() sets the red, green, and blue components of each pixel to the image background color and the opacity component to the specified level of transparency. The background color is defined by the background_color member of the image.

The format of the SetImage method is:

> void SetImage ( Image *image, const Quantum opacity );

A description of each parameter follows:

image:

  The image.

opacity:

  Set each pixel to this level of transparency.

## SetImageChannelDepth

> SetImageChannelDepth() translates the pixel quantums in the specified channel so that if they are later divided to fit within the specified bit depth, that no additional information is lost ( i.e. no remainder resulting from the division ) . Note that any subsequent image processing is likely to increase the effective depth of the image channels. A non-zero value is returned if the operation is successful. Check the exception member of image to determine the cause for any failure.

The format of the SetImageChannelDepth method is:

        unsigned int GetImageChannelDepth(const Image *image,
                      const ChannelType channel,const unsigned int depth)

A description of each parameter follows:

image:

  The image to update.

channel:

  Channel to modify.

depth:

  Desired channel depth (range 1 to QuantumDepth)

## SetImageClipMask

> SetImageClipMask() associates a clip mask with the image. The clip mask must be the same dimensions as the image. Set any pixel component of the clip mask to TransparentOpacity to prevent that corresponding image pixel component from being updated when SyncImagePixels ( ) is applied.

The clip mask protects the DirectClass pixels and PseudoClass pixel indexes from modification. The clip mask does *not* protect the image colormap since the image colormap is globally shared by all pixels in a PseudoClass image.

The format of the SetImageClipMask method is:

> unsigned int SetImageClipMask ( Image *image, Image *clip_mask );

A description of each parameter follows:

image:

  The image.

clip_mask:

  The image clip mask.

## SetImageDepth

> SetImageDepth() translates the pixel quantums across all of the channels so that if they are later divided to fit within the specified bit depth, that no additional information is lost ( i.e. no remainder will result from the division ) . Note that any subsequent image processing is likely to increase the effective depth of the image channels. A non-zero value is returned if the operation is successful. Check the exception member of image to determine the cause for any failure.

The format of the SetImageDepth method is:

> unsigned int SetImageDepth ( Image *image, const unsigned long depth );

A description of each parameter follows:

image:

  The image to update.

depth:

  Desired image depth (range 1 to QuantumDepth)

## SetImageOpacity

> SetImageOpacity() attenuates the opacity channel of an image. If the image pixels are opaque, they are set to the specified opacity level. Otherwise, the pixel opacity values are blended with the supplied transparency value.

The format of the SetImageOpacity method is:

> void SetImageOpacity ( Image *image, const unsigned int opacity );

A description of each parameter follows:

image:

  The image.

opacity:

  The level of transparency: 0 is fully opaque and MaxRGB is fully transparent.

## SetImageType

> SetImageType() sets the type of image. Choose from these types:

          Bilevel        Grayscale       GrayscaleMatte
          Palette        PaletteMatte    TrueColor
          TrueColorMatte ColorSeparation ColorSeparationMatte
          OptimizeType

The format of the SetImageType method is:

> SetImageType ( Image *image, const ImageType image_type );

A description of each parameter follows:

image:

  The image.

image_type:

  Image type.

## TextureImage

> TextureImage() repeatedly tiles the texture image across and down the image canvas. False is returned if an error is encountered.

The format of the TextureImage method is:

> unsigned int TextureImage ( Image *image, const Image *texture );

A description of each parameter follows:

image:

  The image.

texture:

  This image is the texture to layer on the background.