>K K C API: ImageMagick - Image Processing and Display Packageè + < W<8 S




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:


c* ImageMagick'Methods to Constitute an Image

b* ImageMagick&Methods to Composite an Image

^* ImageMagickImage Methods

Z* Methods(to Count the Colors in an Image

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

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

[* Methodsto Resize an Image

^* Methodsto Transform an Image

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

\* Methodsto Enhance an Image

_* ImageMagickImage Effects Methods

[* ImageMagick Special Effects Methods

a* ImageMagick!Image Decoration Methods

\* Image Text Attributes Methods


]* Methodsto Annotate an Image

[* Methodsto Draw on an Image

x* Image Vector Drawing Methods

`* ImageMagick+Methods to Create Image Thumbnails

\* Methods3to Interactively Display and Edit an Image

\* Methods3to Interactively Animate an Image Sequence

Z* Methods#to Get or Set Image Pixels

Y* Workingwith Image Lists

c* ImageMagickCache Views Methods

Y* ImagePixel FIFO

Y* Methods.to Read or Write Binary Large OBjects

[* Methods2to Read or List ImageMagick Image formats

^* Methods1to Compute a Message Digest for an Image

a* ImageMagickRegistry Methods

^* ImageMagickError Methods

_* ImageMagick"Memory Allocation Methods

a* ImageMagick%Resource Consumption Methods

`* ImageMagick!Progress Monitor Methods



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.C

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

    #include <stdio.h>)    #include <string.h>'    #include <time.h>,    #include <sys/types.h>-    #include <magick/api.h>1    int main(int argc,char **argv)    {,      ExceptionInfo5        exception;$      Image2        *image,3        *images,9        *resize_image,7        *thumbnails;(      ImageInfo7        *image_info;!      /*a        Initialize the image info structure and read an image.!      */7      InitializeMagick(*argv);<      GetExceptionInfo(&exception);M      image_info=CloneImageInfo((ImageInfo *) NULL);O      (void) strcpy(image_info->filename,"image.gif");K      images=ReadImage(image_info,&exception);L      if (exception.severity != UndefinedException)J        CatchException(&exception);<      if (images == (Image *) NULL)3        exit(1);!      /*U        Turn the images into a thumbnail sequence.!      */9      thumbnails=NewImageList();X      while ((image=ShiftImageList(&images)) != (Image *) NULL)       {t        resize_image=ResizeImage(image,106,80,MitchellFilter,1.0,&exception);N        if (resize_image == (Image *) NULL)~          MagickError(exception.severity,exception.reason,exception.description);e        (void) PushImageList(&thumbnails,resize_image,&exception);?        DestroyImage(image);F        DestroyImage(resize_image);       }!      /*R        Write the image as MIFF and destroy it.!      */P      (void) strcpy(thumbnails->filename,"image.miff");A      WriteImage(image_info,thumbnails);<      DestroyImageList(thumbnails);<      DestroyImageInfo(image_info);@      DestroyExceptionInfo(&exception);/      DestroyMagick();)      return(0);    }
FNow we need to compile. On Unix, the command would look something likethis:
8    setenv LD_LIBRARY_PATH /usr/local/libb    gcc `Magick-config --cflags --cppflags` demo.c `Magick-config --ldflags --libs`
GAnother example is smile.c. Compile and excute it*to display a smiley face on your X server.

For C++, use:u

    g++ `Magick++-config --cxxflags --cppflags` demo.cpp `Magick++-config --ldflags --libs`

>

9Image manipulation software that works like magic.