=ImageMagick - Application Programmer Interface9NF,
DImage Magick


DImageMagick has a number of functions that allow you to read,Gmanipulate, write, or display an image. These functions are accessibleIthrough the various tools or the object-orientedJPerl interface, PerlMagick. However, you can alsoBaccess the functions directly from your program through the MagickNApplication Programmer Interface. To invoke the functions, write your programNin your favorite language while making calls to the Magick image functions andMlink with libMagick.a, libMagick.so, or Magick.dlldepending on your system.

/The API is divided into a number of categories:

>
*? X11 Utility Methods for ImageMagick>
*S Methods to Interactively Animate an Image Sequence>
*G Methods to Count the Colors in an Image>
*H Image Compression/Decompression Coders>
*= Methods to Read Image Formats>
*I Methods to Read/Write/Invoke Delegates>
*S Methods to Interactively Display and Edit an Image>
*B ImageMagick Image Effects Methods>
*> Methods to Write Image Formats>
*8 ImageMagick Error Methods>
*D Graphic Gems - Graphic Support Methods>
*8 ImageMagick Image Methods>
*G Macintosh Utility Methods for ImageMagick>
*Q Methods to Read or List ImageMagick Image formats>
*E ImageMagick Memory Allocation Methods>
*E ImageMagick Progress Monitor Methods>
*G Windows NT Utility Methods for ImageMagick>
*[ Methods to Reduce the Number of Unique Colors in an Image>
*\ Methods to Segment an Image with Thresholding Fuzzy c-Means>
*X Methods to Shear or Rotate an Image by an Arbitrary Angle>
*V Methods to Compute a Digital Signature for an Image>
*< ImageMagick Utility Methods>
*A VMS Utility Methods for ImageMagick>
*J X11 User Interface Methods for ImageMagick


GHere is a sample program to get you started. To find out about all theEfunctions that are available, read the source code. Each function isHdelinated with a full rows of percent signs with comments describing theKparameters required for the function and what it does. For ease in findingEa function, they are sorted in alphabetical order. Most of the image?functions are found in image.c and effects.c.

JHere is a full example of a program, example.c, that reads a JPEGJimage, creates a thumbnail, and writes it to disk in the GIF image format.



    #include <magick.h>"    int main(int argc,char **argv)    {      Image        *image,        *scaled_image;      ImageInfo        image_info;      /*>        Initialize the image info structure and read an image.      */       GetImageInfo(&image_info);5      (void) strcpy(image_info.filename,"image.jpg");#      image=ReadImage(&image_info);"      if (image == (Image *) NULL)        exit(1);      /*(        Turn the image into a thumbnail.      */+      scaled_image=ZoomImage(image,106,80);)      if (scaled_image != (Image *) NULL)	        {          DestroyImage(image);          image=scaled_image;	        }      /*.        Write the image as GIF and destroy it.      */4      (void) strcpy(image->filename,"image.gif");$      WriteImage(&image_info,image);      DestroyImage(image);    }


GNow we need to compile. On Unix, the command would look something likethis:



<    cc -o example -O -I/usr/local/include/magick example.c \0      -L/usr/local/lib -ljpeg -lMagick -lX11 -lm


KAnother example is smile.c. Compile and excute it to'display a smiley face on your X server.

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



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


2Home PageIImage manipulation software that works like magic.