wand.c 1.2 KB

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