Home | History | Annotate | Download | only in source
      1 #include <stdio.h>
      2 #include <stdlib.h>
      3 #include <wand/MagickWand.h>
      4 
      5 int main(int argc,char **argv)
      6 {
      7 #define ThrowWandException(wand) \
      8 { \
      9   char \
     10     *description; \
     11  \
     12   ExceptionType \
     13     severity; \
     14  \
     15   description=MagickGetException(wand,&severity); \
     16   (void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description); \
     17   description=(char *) MagickRelinquishMemory(description); \
     18   exit(-1); \
     19 }
     20 
     21   MagickBooleanType
     22     status;
     23 
     24   MagickWand
     25     *magick_wand;
     26 
     27   if (argc != 3)
     28     {
     29       (void) fprintf(stdout,"Usage: %s image thumbnail\n",argv[0]);
     30       exit(0);
     31     }
     32   /*
     33     Read an image.
     34   */
     35   MagickWandGenesis();
     36   magick_wand=NewMagickWand();
     37   status=MagickReadImage(magick_wand,argv[1]);
     38   if (status == MagickFalse)
     39     ThrowWandException(magick_wand);
     40   /*
     41     Turn the images into a thumbnail sequence.
     42   */
     43   MagickResetIterator(magick_wand);
     44   while (MagickNextImage(magick_wand) != MagickFalse)
     45     MagickResizeImage(magick_wand,106,80,LanczosFilter,1.0);
     46   /*
     47     Write the image then destroy it.
     48   */
     49   status=MagickWriteImages(magick_wand,argv[2],MagickTrue);
     50   if (status == MagickFalse)
     51     ThrowWandException(magick_wand);
     52   magick_wand=DestroyMagickWand(magick_wand);
     53   MagickWandTerminus();
     54   return(0);
     55 }
     56