Image Magick

ImageMagick 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 libMagick.a, libMagick.so, or Magick.dll
depending on your system.

The API is divided into a number of categories:

* X11 Utility Methods for ImageMagick
* Methods to Interactively Animate an Image Sequence
* Methods to Count the Colors in an Image
* Image Compression/Decompression Coders
* Methods to Read Image Formats
* Methods to Read/Write/Invoke Delegates
* Methods to Interactively Display and Edit an Image
* ImageMagick Image Effects Methods
* Methods to Write Image Formats
* ImageMagick Error Methods
* Graphic Gems - Graphic Support Methods
* ImageMagick Image Methods
* Macintosh Utility Methods for ImageMagick
* Methods to Read or List ImageMagick Image formats
* ImageMagick Memory Allocation Methods
* ImageMagick Progress Monitor Methods
* 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
* Methods to Shear or Rotate an Image by an Arbitrary Angle
* Methods to Compute a Digital Signature for an Image
* ImageMagick Utility Methods
* VMS Utility Methods for ImageMagick
* X11 User Interface Methods for ImageMagick

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 delinated 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, example.c, that reads a JPEG image, 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);
      (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.
      */
      (void) strcpy(image->filename,"image.gif");
      WriteImage(&image_info,image);
      DestroyImage(image);
    }

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

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

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

If you compile with C++ you must undefine class (since it is a C++ reserved word). The class element of the Image structure in C++ is defined as c_class. Both of these requirements are illustrated here:

    #include <magick.h>
    #if defined(__cplusplus) || defined(c_plusplus)
    #undef class
    #endif

    ...

    if (image->c_class == DirectClass)


Home Page Image manipulation software that works like magic.