=ImageMagick - Application Programmer Interface4NF,
F[Image 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:

>
*G Utility Routines to Read Image Formats >
*G Utility Routines to Write Image Formats>
*F ImageMagick Image Manipulation Routines>
*C ImageMagick Image Effects Routines>
*E Graphic Gems - Graphic Support Routines>
*P Reduce the Number of Unique Colors in an Image>
*< Count the Colors in an Image>
*? Shear or rotate a raster image by an arbitrary angle>
*M Segment an Image with Thresholding and the Fuzzy c-Means Technique>
*9 ImageMagick Error Routines>
*F ImageMagick Progress Monitor Routines>
*F Compute a Digital Signature for a Image Colormap>
*H Image Compression/Decompression Coders>
*= ImageMagick Utility Routines>
*? X11 Utility Routines for ImageMagick>
*K X11 User Interface Routines for ImageMagick>
*G Windows NT Utility Routines for ImageMagick>
*G Macintosh Utility Routines for ImageMagick>
*A VMS Utility Routines 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,MitchellFilter);)      if (scaled_image != (Image *) NULL)	        {          DestroyImage(image);          image=scaled_image;	        }      /*.        Write the image as GIF and destroy it.      */5      (void) strcpy(image_info.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 \)      -L/usr/local/lib -lMagick -lX11 -lm


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)


4[home page]IImage manipulation software that works like magic.