1#include <stdio.h>
2#include <stdlib.h>
3#include <string.h>
4#include <time.h>
5#include <magick/MagickCore.h>
6
7int main(int argc,char **argv)
8{
9  ExceptionInfo
10    *exception;
11
12  Image
13    *image,
14    *images,
15    *resize_image,
16    *thumbnails;
17
18  ImageInfo
19    *image_info;
20
21  if (argc != 3)
22    {
23      (void) fprintf(stdout,"Usage: %s image thumbnail\n",argv[0]);
24      exit(0);
25    }
26  /*
27    Initialize the image info structure and read an image.
28  */
29  MagickCoreGenesis(*argv,MagickTrue);
30  exception=AcquireExceptionInfo();
31  image_info=CloneImageInfo((ImageInfo *) NULL);
32  (void) strcpy(image_info->filename,argv[1]);
33  images=ReadImage(image_info,exception);
34  if (exception->severity != UndefinedException)
35    CatchException(exception);
36  if (images == (Image *) NULL)
37    exit(1);
38  /*
39    Convert the image to a thumbnail.
40  */
41  thumbnails=NewImageList();
42  while ((image=RemoveFirstImageFromList(&images)) != (Image *) NULL)
43  {
44    resize_image=ResizeImage(image,106,80,LanczosFilter,1.0,exception);
45    if (resize_image == (Image *) NULL)
46      MagickError(exception->severity,exception->reason,exception->description);
47    (void) AppendImageToList(&thumbnails,resize_image);
48    DestroyImage(image);
49  }
50  /*
51    Write the image thumbnail.
52  */
53  (void) strcpy(thumbnails->filename,argv[2]);
54  WriteImage(image_info,thumbnails);
55  /*
56    Destroy the image thumbnail and exit.
57  */
58  thumbnails=DestroyImageList(thumbnails);
59  image_info=DestroyImageInfo(image_info);
60  exception=DestroyExceptionInfo(exception);
61  MagickCoreTerminus();
62  return(0);
63}
64