[Home] [Mission Statement] [Development Process] [Contribute] [Download] [Installation] [CVS] [Mailing Lists] [FAQ] [Formats] [News ] [ChangeLog] [Report Bugs] [Utilities] [Programming] [Books] [Links]

Search GraphicsMagick site

GraphicsMagick has a number of functions that allow you to read, manipulate, write, or display an image. These functions are accessible through the various tools or the object-oriented Perl interface, PerlMagick. However, you can also access the functions directly from your program through the Magick Application Programmer Interface. To invoke the functions, write your program in your favorite language while making calls to the Magick image functions and link with libGraphicsMagick.a, libGraphicsMagick.so, or Magick.dll depending on your system.

The API is divided into a number of categories:

* GraphicsMagick Methods to Constitute an Image
* GraphicsMagick Methods to Composite an Image
* GraphicsMagick Image Methods
* 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
* Methods to Resize an Image
* Methods to Transform an Image
* Methods to Shear or Rotate an Image by an Arbitrary Angle
* Methods to Enhance an Image
* GraphicsMagick Image Effects Methods
* GraphicsMagick Special Effects Methods
* GraphicsMagick Image Decoration Methods
* Image Text Attributes Methods
* Methods to Annotate an Image
* Methods to Paint on an Image
* Methods to Draw on an Image
* Image Vector Drawing Methods
* GraphicsMagick Methods to Create Image Thumbnails
* Methods to Interactively Display and Edit an Image
* Methods to Interactively Animate an Image Sequence
* Methods to Get or Set Image Pixels
* Working with Image Lists
* GraphicsMagick Cache Views Methods
* Image Pixel FIFO
* Methods to Read or Write Binary Large OBjects
* Methods to Read or List GraphicsMagick Image formats
* Methods to Compute a Message Digest for an Image
* GraphicsMagick Registry Methods
* GraphicsMagick Error Methods
* GraphicsMagick Memory Allocation Methods
* GraphicsMagick Resource Consumption Methods
* GraphicsMagick Progress Monitor Methods



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

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

 #include <stdio.h>
 #include <string.h>
 #include <time.h>
 #include <sys/types.h>
 #include <magick/api.h>

 int main(int argc,char **argv)
 {
 ExceptionInfo
 exception;

 Image
 *image,
 *images,
 *resize_image,
 *thumbnails;

 ImageInfo
 *image_info;

 /*
 Initialize the image info structure and read an image.
 */
 InitializeMagick(*argv);
 GetExceptionInfo(&exception);
 image_info=CloneImageInfo((ImageInfo *) NULL);
 (void) strcpy(image_info->filename,"image.gif");
 images=ReadImage(image_info,&exception);
 if (exception.severity != UndefinedException)
 CatchException(&exception);
 if (images == (Image *) NULL)
 exit(1);
 /*
 Turn the images into a thumbnail sequence.
 */
 thumbnails=NewImageList();
 while ((image=RemoveFirstImageFromList(ℑs)) != (Image *) NULL)
 {
 resize_image=ResizeImage(image,106,80,Lanczos,1.0,&exception);
 if (resize_image == (Image *) NULL)
 MagickError(exception.severity,exception.reason,exception.description);
 (void) AppendImageToList(&thumbnails,resize_image,&exception);
 DestroyImage(image);
 DestroyImage(resize_image);
 }
 /*
 Write the image as MIFF and destroy it.
 */
 (void) strcpy(thumbnails->filename,"image.miff");
 WriteImage(image_info,thumbnails);
 DestroyImageList(thumbnails);
 DestroyImageInfo(image_info);
 DestroyExceptionInfo(&exception);
 DestroyMagick();
 return(0);
 }

Now we need to compile. On Unix, the command would look something like this:

 setenv LD_LIBRARY_PATH /usr/local/lib
 gcc `GraphicsMagick-config --cflags --cppflags` demo.c `GraphicsMagick-config --ldflags --libs`

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

For C++, use:

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

GraphicsMagick Home PageGraphicsMagick Home Page Image manipulation software that works like magic.