=J D H C ImageMagick - Image Processing and Display Package; C
F Image Magick



G

ImageMagick has a number of functions that allow you to read,Fmanipulate, write, or display an image. These functions are accessibleIthrough the various tools or the object-orientedIPerl interface, PerlMagick. However, you can alsoNaccess the functions directly from your program through the Magick ApplicationIProgrammer Interface. To invoke the functions, write your program in yourFfavorite language while making calls to the Magick image functions andMlink with libMagick.a, libMagick.so, or Magick.dlldepending on your system.2

The API is divided into a number of categories:


^* ImageMagickImage Methods

Y* Methodsto Resize an Image

^* Methodsto Transform an Image

Y* Methodsto Draw on an Image

]* Methodsto Annotate an Image

[* Methods(to Count the Colors in an Image

a* ImageMagick!Image Decoration Methods

`* ImageMagick+Methods to Create Image Thumbnails

`* ImageMagickImage Effects Methods

\* Methodsto Enhance an Image

]* Methods:to Reduce the Number of Unique Colors in an Image

\* Methods<to Segment an Image with Thresholding Fuzzy c-Means

Z* Methods:to Shear or Rotate an Image by an Arbitrary Angle

^* Methods4to Compute a Digital Signature for an Image

^* ImageMagickPixel Cache Methods

Y* Methods.to Read or Write Binary Large OBjects

[* Methods2to Read or List ImageMagick Image formats

^* ImageMagickError Methods

_* ImageMagick"Memory Allocation Methods

`* ImageMagick!Progress Monitor Methods

\* Methods3to Interactively Display and Edit an Image

\* Methods3to Interactively Animate an Image Sequence

FHere is a sample program to get you started. To find out about all theOfunctions that are available, read the source code. Each function is delineatedIwith a full rows of percent signs with comments describing the parametersKrequired for the function and what it does. For ease in finding a function,Fthey are sorted in alphabetical order. Most of the image functions are1found in image.c and effects.c.F

Here is a full example of a program, example.c, that readsIa JPEG image, creates a thumbnail, and writes it to disk in the GIF imageformat.1

    #include <magick.h>1    int main(int argc,char **argv)    {$      Image2        *image,9        *scaled_image;(      ImageInfo6        image_info;!      /*a        Initialize the image info structure and read an image.!      */=      GetImageInfo(&image_info);N      (void) strcpy(image_info.filename,"image.jpg");@      image=ReadImage(&image_info);;      if (image == (Image *) NULL)3        exit(1);!      /*K        Turn the image into a thumbnail.!      */D      scaled_image=ZoomImage(image,106,80);B      if (scaled_image != (Image *) NULL),        {K          DestroyImage(image);J          image=scaled_image;,        }!      /*Q        Write the image as GIF and destroy it.!      */M      (void) strcpy(image->filename,"image.png");A      WriteImage(&image_info,image);3      DestroyImage(image);    }
FNow we need to compile. On Unix, the command would look something likethis:P
    cc -o example -O -I/usr/local/include/magick example.c \Z      -L/usr/local/lib -lMagick -ltiff -ljpeg -lX11 -lz -lm
GAnother example is smile.c. Compile and excute it*to display a smiley face on your X server.H

If you compile with C++ you must undefine class (since it isFa C++ reserved word). The class element of the ImageKstructure in C++ is defined as c_class. Both of these requirementsare illustrated here:1

    #include <magick.h>B    #if defined(__cplusplus) || defined(c_plusplus)    #undef class    #endif    ...>    if (image->c_class == DirectClass)


Home Page  9Image manipulation software that works like magic.