[
About ImageMagick
Command-line Tools
Program Interfaces
] [ Install from Source Binary Releases Resources ] [ Download ] [ Links ] [ Sponsors Consumer Reviews and Ratings ] |
The MagickCore API is a low-level interface between the C programming language and the ImageMagick image processing libraries and is recommended for wizard-level programmers only. Unlike the MagickWand C API which uses only a few opaque types and accessors, with MagickCore you almost exlusively access the structure members directly. A description of the MagickCore public methods are found here:
After you write your MagickCore program, compile it like this: cc `Magick-config --cflags --cppflags` core.c `Magick-config --ldflags --libs` Here is a example program that utilizes the MagickCore API to get you started, core.c. It reads a GIF image, creates a thumbnail, and writes it to disk in the PNG image format. #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <magick/ImageMagick.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(&images)) != (Image *) NULL) { resize_image=ResizeImage(image,106,80,LanczosFilter,1.0,&exception); if (resize_image == (Image *) NULL) MagickError(exception.severity,exception.reason,exception.description); (void) AppendImageToList(&thumbnails,resize_image); DestroyImage(image); } /* Write the image as MIFF and destroy it. */ (void) strcpy(thumbnails->filename,"image.png"); WriteImage(image_info,thumbnails); thumbnails=DestroyImageList(thumbnails); image_info=DestroyImageInfo(image_info); DestroyExceptionInfo(&exception); DestroyMagick(); return(0); } |