1/*
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3%                                                                             %
4%                                                                             %
5%                                                                             %
6%                AAA   N   N  IIIII  M   M   AAA   TTTTT  EEEEE               %
7%               A   A  NN  N    I    MM MM  A   A    T    E                   %
8%               AAAAA  N N N    I    M M M  AAAAA    T    EEE                 %
9%               A   A  N  NN    I    M   M  A   A    T    E                   %
10%               A   A  N   N  IIIII  M   M  A   A    T    EEEEE               %
11%                                                                             %
12%                                                                             %
13%              Methods to Interactively Animate an Image Sequence             %
14%                                                                             %
15%                             Software Design                                 %
16%                                  Cristy                                     %
17%                                July 1992                                    %
18%                                                                             %
19%                                                                             %
20%  Copyright 1999-2016 ImageMagick Studio LLC, a non-profit organization      %
21%  dedicated to making software imaging solutions freely available.           %
22%                                                                             %
23%  You may not use this file except in compliance with the License.  You may  %
24%  obtain a copy of the License at                                            %
25%                                                                             %
26%    http://www.imagemagick.org/script/license.php                            %
27%                                                                             %
28%  Unless required by applicable law or agreed to in writing, software        %
29%  distributed under the License is distributed on an "AS IS" BASIS,          %
30%  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   %
31%  See the License for the specific language governing permissions and        %
32%  limitations under the License.                                             %
33%                                                                             %
34%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35%
36%  Use the animate program to animate an image sequence on any X server.
37%
38*/
39
40/*
41  Include declarations.
42*/
43#include "MagickWand/studio.h"
44#include "MagickWand/MagickWand.h"
45#include "MagickWand/mogrify-private.h"
46#include "MagickCore/animate-private.h"
47#include "MagickCore/string-private.h"
48
49/*
50%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
51%                                                                             %
52%                                                                             %
53%                                                                             %
54+   A n i m a t e I m a g e C o m m a n d                                     %
55%                                                                             %
56%                                                                             %
57%                                                                             %
58%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59%
60%  AnimateImageCommand() displays a sequence of images on any workstation
61%  display running an X server. Animate first determines the hardware
62%  capabilities of the workstation. If the number of unique colors in an image
63%  is less than or equal to the number the workstation can support, the image
64%  is displayed in an X window. Otherwise the number of colors in the image is
65%  first reduced to match the color resolution of the workstation before it is
66%  displayed.
67%
68%  This means that a continuous-tone 24 bits/pixel image can display on a 8
69%  bit pseudo-color device or monochrome device. In most instances the reduced
70%  color image closely resembles the original. Alternatively, a monochrome or
71%  pseudo-color image sequence can display on a continuous-tone 24 bits/pixels
72%  device.
73%
74%  The format of the AnimateImageCommand method is:
75%
76%      MagickBooleanType AnimateImageCommand(ImageInfo *image_info,int argc,
77%        char **argv,char **metadata,ExceptionInfo *exception)
78%
79%  A description of each parameter follows:
80%
81%    o image_info: the image info.
82%
83%    o argc: the number of elements in the argument vector.
84%
85%    o argv: A text array containing the command line arguments.
86%
87%    o metadata: any metadata is returned here.
88%
89%    o exception: return any errors or warnings in this structure.
90%
91*/
92
93static MagickBooleanType AnimateUsage(void)
94{
95  const char
96    **p;
97
98  static const char
99    *buttons[]=
100    {
101      "Press any button to map or unmap the Command widget",
102      (char *) NULL
103    },
104    *miscellaneous[]=
105    {
106      "-debug events        display copious debugging information",
107      "-help                print program options",
108      "-list type           print a list of supported option arguments",
109      "-log format          format of debugging information",
110      "-version             print version information",
111      (char *) NULL
112    },
113    *operators[]=
114    {
115      "-channel mask        set the image channel mask",
116      "-colors value        preferred number of colors in the image",
117      "-crop geometry       preferred size and location of the cropped image",
118      "-extract geometry    extract area from image",
119      "-monochrome          transform image to black and white",
120      "-repage geometry     size and location of an image canvas (operator)",
121      "-resample geometry   change the resolution of an image",
122      "-resize geometry     resize the image",
123      "-rotate degrees      apply Paeth rotation to the image",
124      "-strip               strip image of all profiles and comments",
125      "-thumbnail geometry  create a thumbnail of the image",
126      "-trim                trim image edges",
127      (char *) NULL
128    },
129    *settings[]=
130    {
131      "-alpha option        on, activate, off, deactivate, set, opaque, copy",
132      "                     transparent, extract, background, or shape",
133      "-authenticate password",
134      "                     decipher image with this password",
135      "-backdrop            display image centered on a backdrop",
136      "-colormap type       Shared or Private",
137      "-colorspace type     alternate image colorspace",
138      "-decipher filename   convert cipher pixels to plain pixels",
139      "-define format:option",
140      "                     define one or more image format options",
141      "-delay value         display the next image after pausing",
142      "-density geometry    horizontal and vertical density of the image",
143      "-depth value         image depth",
144      "-display server      display image to this X server",
145      "-dispose method      layer disposal method",
146      "-dither method       apply error diffusion to image",
147      "-filter type         use this filter when resizing an image",
148      "-format \"string\"     output formatted image characteristics",
149      "-gamma value         level of gamma correction",
150      "-geometry geometry   preferred size and location of the Image window",
151      "-gravity type        horizontal and vertical backdrop placement",
152      "-identify            identify the format and characteristics of the image",
153      "-immutable           displayed image cannot be modified",
154      "-interlace type      type of image interlacing scheme",
155      "-interpolate method  pixel color interpolation method",
156      "-limit type value    pixel cache resource limit",
157      "-loop iterations     loop images then exit",
158      "-matte               store matte channel if the image has one",
159      "-map type            display image using this Standard Colormap",
160      "-monitor             monitor progress",
161      "-pause               seconds to pause before reanimating",
162      "-page geometry       size and location of an image canvas (setting)",
163      "-quantize colorspace reduce colors in this colorspace",
164      "-quiet               suppress all warning messages",
165      "-regard-warnings     pay attention to warning messages",
166      "-remote command      execute a command in an remote display process",
167      "-respect-parentheses settings remain in effect until parenthesis boundary",
168      "-sampling-factor geometry",
169      "                     horizontal and vertical sampling factor",
170      "-scenes range        image scene range",
171      "-seed value          seed a new sequence of pseudo-random numbers",
172      "-set attribute value set an image attribute",
173      "-size geometry       width and height of image",
174      "-support factor      resize support: > 1.0 is blurry, < 1.0 is sharp",
175      "-transparent-color color",
176      "                     transparent color",
177      "-treedepth value     color tree depth",
178      "-verbose             print detailed information about the image",
179      "-visual type         display image using this visual type",
180      "-virtual-pixel method",
181      "                     virtual pixel access method",
182      "-window id           display image to background of this window",
183      (char *) NULL
184    },
185    *sequence_operators[]=
186    {
187      "-coalesce            merge a sequence of images",
188      "-flatten             flatten a sequence of images",
189      (char *) NULL
190    };
191
192  ListMagickVersion(stdout);
193  (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
194    GetClientName());
195  (void) printf("\nImage Settings:\n");
196  for (p=settings; *p != (char *) NULL; p++)
197    (void) printf("  %s\n",*p);
198  (void) printf("\nImage Operators:\n");
199  for (p=operators; *p != (char *) NULL; p++)
200    (void) printf("  %s\n",*p);
201  (void) printf("\nImage Sequence Operators:\n");
202  for (p=sequence_operators; *p != (char *) NULL; p++)
203    (void) printf("  %s\n",*p);
204  (void) printf("\nMiscellaneous Options:\n");
205  for (p=miscellaneous; *p != (char *) NULL; p++)
206    (void) printf("  %s\n",*p);
207  (void) printf(
208    "\nIn addition to those listed above, you can specify these standard X\n");
209  (void) printf(
210    "resources as command line options:  -background, -bordercolor,\n");
211  (void) printf(
212    "-alpha-color, -borderwidth, -font, -foreground, -iconGeometry,\n");
213  (void) printf("-iconic, -name, -shared-memory, or -title.\n");
214  (void) printf(
215    "\nBy default, the image format of 'file' is determined by its magic\n");
216  (void) printf(
217    "number.  To specify a particular image format, precede the filename\n");
218  (void) printf(
219    "with an image format name and a colon (i.e. ps:image) or specify the\n");
220  (void) printf(
221    "image type as the filename suffix (i.e. image.ps).  Specify 'file' as\n");
222  (void) printf("'-' for standard input or output.\n");
223  (void) printf("\nButtons: \n");
224  for (p=buttons; *p != (char *) NULL; p++)
225    (void) printf("  %s\n",*p);
226  return(MagickFalse);
227}
228
229WandExport MagickBooleanType AnimateImageCommand(ImageInfo *image_info,
230  int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
231{
232#if defined(MAGICKCORE_X11_DELEGATE)
233#define DestroyAnimate() \
234{ \
235  XDestroyResourceInfo(&resource_info); \
236  if (display != (Display *) NULL) \
237    { \
238      XCloseDisplay(display); \
239      display=(Display *) NULL; \
240    } \
241  XDestroyResourceInfo(&resource_info); \
242  DestroyImageStack(); \
243  for (i=0; i < (ssize_t) argc; i++) \
244    argv[i]=DestroyString(argv[i]); \
245  argv=(char **) RelinquishMagickMemory(argv); \
246}
247#define ThrowAnimateException(asperity,tag,option) \
248{ \
249  (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
250    option); \
251  DestroyAnimate(); \
252  return(MagickFalse); \
253}
254#define ThrowAnimateInvalidArgumentException(option,argument) \
255{ \
256  (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
257    "InvalidArgument","'%s': %s",option,argument); \
258  DestroyAnimate(); \
259  return(MagickFalse); \
260}
261
262  char
263    *resource_value,
264    *server_name;
265
266  const char
267    *option;
268
269  Display
270    *display;
271
272  Image
273    *image;
274
275  ImageStack
276    image_stack[MaxImageStackDepth+1];
277
278  MagickBooleanType
279    fire,
280    pend,
281    respect_parenthesis;
282
283  MagickStatusType
284    status;
285
286  QuantizeInfo
287    *quantize_info;
288
289  register ssize_t
290    i;
291
292  ssize_t
293    j,
294    k;
295
296  XResourceInfo
297    resource_info;
298
299  XrmDatabase
300    resource_database;
301
302  /*
303    Set defaults.
304  */
305  assert(image_info != (ImageInfo *) NULL);
306  assert(image_info->signature == MagickCoreSignature);
307  if (image_info->debug != MagickFalse)
308    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
309  assert(exception != (ExceptionInfo *) NULL);
310  if (argc == 2)
311    {
312      option=argv[1];
313      if ((LocaleCompare("version",option+1) == 0) ||
314          (LocaleCompare("-version",option+1) == 0))
315        {
316          ListMagickVersion(stdout);
317          return(MagickTrue);
318        }
319    }
320  status=MagickTrue;
321  SetNotifyHandlers;
322  display=(Display *) NULL;
323  j=1;
324  k=0;
325  NewImageStack();
326  option=(char *) NULL;
327  pend=MagickFalse;
328  respect_parenthesis=MagickFalse;
329  resource_database=(XrmDatabase) NULL;
330  (void) ResetMagickMemory(&resource_info,0,sizeof(XResourceInfo));
331  server_name=(char *) NULL;
332  status=MagickTrue;
333  /*
334    Check for server name specified on the command line.
335  */
336  ReadCommandlLine(argc,&argv);
337  status=ExpandFilenames(&argc,&argv);
338  if (status == MagickFalse)
339    ThrowAnimateException(ResourceLimitError,"MemoryAllocationFailed",
340      image_info->filename);
341  for (i=1; i < (ssize_t) argc; i++)
342  {
343    /*
344      Check command line for server name.
345    */
346    option=argv[i];
347    if (LocaleCompare("display",option+1) == 0)
348      {
349        /*
350          User specified server name.
351        */
352        i++;
353        if (i == (ssize_t) argc)
354          ThrowAnimateException(OptionError,"MissingArgument",option);
355        server_name=argv[i];
356      }
357    if ((LocaleCompare("help",option+1) == 0) ||
358        (LocaleCompare("-help",option+1) == 0))
359      return(AnimateUsage());
360  }
361  /*
362    Get user defaults from X resource database.
363  */
364  display=XOpenDisplay(server_name);
365  if (display == (Display *) NULL)
366    ThrowAnimateException(XServerError,"UnableToOpenXServer",
367      XDisplayName(server_name));
368  (void) XSetErrorHandler(XError);
369  resource_database=XGetResourceDatabase(display,GetClientName());
370  XGetResourceInfo(image_info,resource_database,GetClientName(),
371    &resource_info);
372  quantize_info=resource_info.quantize_info;
373  image_info->density=XGetResourceInstance(resource_database,GetClientName(),
374    "density",(char *) NULL);
375  if (image_info->density == (char *) NULL)
376    image_info->density=XGetScreenDensity(display);
377  resource_value=XGetResourceInstance(resource_database,GetClientName(),
378    "interlace","none");
379  image_info->interlace=(InterlaceType)
380    ParseCommandOption(MagickInterlaceOptions,MagickFalse,resource_value);
381  resource_value=XGetResourceInstance(resource_database,GetClientName(),
382    "verbose","False");
383  image_info->verbose=IsStringTrue(resource_value);
384  resource_value=XGetResourceInstance(resource_database,GetClientName(),
385    "dither","True");
386  quantize_info->dither_method=IsStringTrue(resource_value) != MagickFalse ?
387    RiemersmaDitherMethod : NoDitherMethod;
388  /*
389    Parse command line.
390  */
391  for (i=1; i <= (ssize_t) argc; i++)
392  {
393    if (i < (ssize_t) argc)
394      option=argv[i];
395    else
396      if (image != (Image *) NULL)
397        break;
398      else
399        if (isatty(STDIN_FILENO) != MagickFalse)
400          option="logo:";
401        else
402          option="-";
403    if (LocaleCompare(option,"(") == 0)
404      {
405        FireImageStack(MagickFalse,MagickTrue,pend);
406        if (k == MaxImageStackDepth)
407          ThrowAnimateException(OptionError,"ParenthesisNestedTooDeeply",
408            option);
409        PushImageStack();
410        continue;
411      }
412    if (LocaleCompare(option,")") == 0)
413      {
414        FireImageStack(MagickFalse,MagickTrue,MagickTrue);
415        if (k == 0)
416          ThrowAnimateException(OptionError,"UnableToParseExpression",option);
417        PopImageStack();
418        continue;
419      }
420    if (IsCommandOption(option) == MagickFalse)
421      {
422        const char
423          *filename;
424
425        Image
426          *images;
427
428        /*
429          Read input image.
430        */
431        FireImageStack(MagickFalse,MagickFalse,pend);
432        filename=option;
433        if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
434          {
435            option=argv[++i];
436            filename=option;
437          }
438        if (image_info->ping != MagickFalse)
439          images=PingImages(image_info,filename,exception);
440        else
441          images=ReadImages(image_info,filename,exception);
442        status&=(images != (Image *) NULL) &&
443          (exception->severity < ErrorException);
444        if (images == (Image *) NULL)
445          continue;
446        AppendImageStack(images);
447        continue;
448      }
449    pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
450    switch (*(option+1))
451    {
452      case 'a':
453      {
454        if (LocaleCompare("alpha",option+1) == 0)
455          {
456            ssize_t
457              type;
458
459            if (*option == '+')
460              break;
461            i++;
462            if (i == (ssize_t) argc)
463              ThrowAnimateException(OptionError,"MissingArgument",option);
464            type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,argv[i]);
465            if (type < 0)
466              ThrowAnimateException(OptionError,"UnrecognizedAlphaChannelOption",
467                argv[i]);
468            break;
469          }
470        if (LocaleCompare("alpha-color",option+1) == 0)
471          {
472            if (*option == '+')
473              break;
474            i++;
475            if (i == (ssize_t) argc)
476              ThrowAnimateException(OptionError,"MissingArgument",option);
477            resource_info.alpha_color=argv[i];
478            break;
479          }
480        if (LocaleCompare("authenticate",option+1) == 0)
481          {
482            if (*option == '+')
483              break;
484            i++;
485            if (i == (ssize_t) argc)
486              ThrowAnimateException(OptionError,"MissingArgument",option);
487            break;
488          }
489        ThrowAnimateException(OptionError,"UnrecognizedOption",option);
490      }
491      case 'b':
492      {
493        if (LocaleCompare("backdrop",option+1) == 0)
494          {
495            resource_info.backdrop=(*option == '-') ? MagickTrue : MagickFalse;
496            break;
497          }
498        if (LocaleCompare("background",option+1) == 0)
499          {
500            if (*option == '+')
501              break;
502            i++;
503            if (i == (ssize_t) argc)
504              ThrowAnimateException(OptionError,"MissingArgument",option);
505            resource_info.background_color=argv[i];
506            break;
507          }
508        if (LocaleCompare("bordercolor",option+1) == 0)
509          {
510            if (*option == '+')
511              break;
512            i++;
513            if (i == (ssize_t) argc)
514              ThrowAnimateException(OptionError,"MissingArgument",option);
515            resource_info.border_color=argv[i];
516            break;
517          }
518        if (LocaleCompare("borderwidth",option+1) == 0)
519          {
520            resource_info.border_width=0;
521            if (*option == '+')
522              break;
523            i++;
524            if ((i == (ssize_t) argc) || (IsGeometry(argv[i]) == MagickFalse))
525              ThrowAnimateException(OptionError,"MissingArgument",option);
526            resource_info.border_width=(unsigned int)
527              StringToUnsignedLong(argv[i]);
528            break;
529          }
530        ThrowAnimateException(OptionError,"UnrecognizedOption",option);
531      }
532      case 'c':
533      {
534        if (LocaleCompare("cache",option+1) == 0)
535          {
536            if (*option == '+')
537              break;
538            i++;
539            if (i == (ssize_t) argc)
540              ThrowAnimateException(OptionError,"MissingArgument",option);
541            if (IsGeometry(argv[i]) == MagickFalse)
542              ThrowAnimateInvalidArgumentException(option,argv[i]);
543            break;
544          }
545        if (LocaleCompare("channel",option+1) == 0)
546          {
547            ssize_t
548              channel;
549
550            if (*option == '+')
551              break;
552            i++;
553            if (i == (ssize_t) argc)
554              ThrowAnimateException(OptionError,"MissingArgument",option);
555            channel=ParseChannelOption(argv[i]);
556            if (channel < 0)
557              ThrowAnimateException(OptionError,"UnrecognizedChannelType",
558                argv[i]);
559            break;
560          }
561        if (LocaleCompare("clone",option+1) == 0)
562          {
563            Image
564              *clone_images;
565
566            clone_images=image;
567            if (k != 0)
568              clone_images=image_stack[k-1].image;
569            if (clone_images == (Image *) NULL)
570              ThrowAnimateException(ImageError,"UnableToCloneImage",option);
571            FireImageStack(MagickFalse,MagickTrue,MagickTrue);
572            if (*option == '+')
573              clone_images=CloneImages(clone_images,"-1",exception);
574            else
575              {
576                i++;
577                if (i == (ssize_t) argc)
578                  ThrowAnimateException(OptionError,"MissingArgument",option);
579                if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
580                  ThrowAnimateInvalidArgumentException(option,argv[i]);
581                clone_images=CloneImages(clone_images,argv[i],exception);
582              }
583            if (clone_images == (Image *) NULL)
584              ThrowAnimateException(OptionError,"NoSuchImage",option);
585            AppendImageStack(clone_images);
586            break;
587          }
588        if (LocaleCompare("coalesce",option+1) == 0)
589          break;
590        if (LocaleCompare("colormap",option+1) == 0)
591          {
592            resource_info.colormap=PrivateColormap;
593            if (*option == '+')
594              break;
595            i++;
596            if (i == (ssize_t) argc)
597              ThrowAnimateException(OptionError,"MissingArgument",option);
598            resource_info.colormap=UndefinedColormap;
599            if (LocaleCompare("private",argv[i]) == 0)
600              resource_info.colormap=PrivateColormap;
601            if (LocaleCompare("shared",argv[i]) == 0)
602              resource_info.colormap=SharedColormap;
603            if (resource_info.colormap == UndefinedColormap)
604              ThrowAnimateException(OptionError,"UnrecognizedColormapType",
605                argv[i]);
606            break;
607          }
608        if (LocaleCompare("colors",option+1) == 0)
609          {
610            quantize_info->number_colors=0;
611            if (*option == '+')
612              break;
613            i++;
614            if (i == (ssize_t) argc)
615              ThrowAnimateException(OptionError,"MissingArgument",option);
616            if (IsGeometry(argv[i]) == MagickFalse)
617              ThrowAnimateInvalidArgumentException(option,argv[i]);
618            quantize_info->number_colors=StringToUnsignedLong(argv[i]);
619            break;
620          }
621        if (LocaleCompare("colorspace",option+1) == 0)
622          {
623            ssize_t
624              colorspace;
625
626            if (*option == '+')
627              break;
628            i++;
629            if (i == (ssize_t) argc)
630              ThrowAnimateException(OptionError,"MissingArgument",option);
631            colorspace=ParseCommandOption(MagickColorspaceOptions,
632              MagickFalse,argv[i]);
633            if (colorspace < 0)
634              ThrowAnimateException(OptionError,"UnrecognizedColorspace",
635                argv[i]);
636            break;
637          }
638        if (LocaleCompare("concurrent",option+1) == 0)
639          break;
640        if (LocaleCompare("crop",option+1) == 0)
641          {
642            if (*option == '+')
643              break;
644            i++;
645            if (i == (ssize_t) argc)
646              ThrowAnimateException(OptionError,"MissingArgument",option);
647            if (IsGeometry(argv[i]) == MagickFalse)
648              ThrowAnimateInvalidArgumentException(option,argv[i]);
649            break;
650          }
651        ThrowAnimateException(OptionError,"UnrecognizedOption",option);
652      }
653      case 'd':
654      {
655        if (LocaleCompare("debug",option+1) == 0)
656          {
657            ssize_t
658              event;
659
660            if (*option == '+')
661              break;
662            i++;
663            if (i == (ssize_t) argc)
664              ThrowAnimateException(OptionError,"MissingArgument",option);
665            event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
666            if (event < 0)
667              ThrowAnimateException(OptionError,"UnrecognizedEventType",
668                argv[i]);
669            (void) SetLogEventMask(argv[i]);
670            break;
671          }
672        if (LocaleCompare("decipher",option+1) == 0)
673          {
674            if (*option == '+')
675              break;
676            i++;
677            if (i == (ssize_t) argc)
678              ThrowAnimateException(OptionError,"MissingArgument",option);
679            break;
680          }
681        if (LocaleCompare("define",option+1) == 0)
682          {
683            i++;
684            if (i == (ssize_t) argc)
685              ThrowAnimateException(OptionError,"MissingArgument",option);
686            if (*option == '+')
687              {
688                const char
689                  *define;
690
691                define=GetImageOption(image_info,argv[i]);
692                if (define == (const char *) NULL)
693                  ThrowAnimateException(OptionError,"NoSuchOption",argv[i]);
694                break;
695              }
696            break;
697          }
698        if (LocaleCompare("delay",option+1) == 0)
699          {
700            if (*option == '+')
701              break;
702            i++;
703            if (i == (ssize_t) argc)
704              ThrowAnimateException(OptionError,"MissingArgument",option);
705            if (IsGeometry(argv[i]) == MagickFalse)
706              ThrowAnimateInvalidArgumentException(option,argv[i]);
707            break;
708          }
709        if (LocaleCompare("density",option+1) == 0)
710          {
711            if (*option == '+')
712              break;
713            i++;
714            if (i == (ssize_t) argc)
715              ThrowAnimateException(OptionError,"MissingArgument",option);
716            if (IsGeometry(argv[i]) == MagickFalse)
717              ThrowAnimateInvalidArgumentException(option,argv[i]);
718            break;
719          }
720        if (LocaleCompare("depth",option+1) == 0)
721          {
722            if (*option == '+')
723              break;
724            i++;
725            if (i == (ssize_t) argc)
726              ThrowAnimateException(OptionError,"MissingArgument",option);
727            if (IsGeometry(argv[i]) == MagickFalse)
728              ThrowAnimateInvalidArgumentException(option,argv[i]);
729            break;
730          }
731        if (LocaleCompare("display",option+1) == 0)
732          {
733            if (*option == '+')
734              break;
735            i++;
736            if (i == (ssize_t) argc)
737              ThrowAnimateException(OptionError,"MissingArgument",option);
738            break;
739          }
740        if (LocaleCompare("dispose",option+1) == 0)
741          {
742            ssize_t
743              dispose;
744
745            if (*option == '+')
746              break;
747            i++;
748            if (i == (ssize_t) argc)
749              ThrowAnimateException(OptionError,"MissingArgument",option);
750            dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
751            if (dispose < 0)
752              ThrowAnimateException(OptionError,"UnrecognizedDisposeMethod",
753                argv[i]);
754            break;
755          }
756        if (LocaleCompare("dither",option+1) == 0)
757          {
758            ssize_t
759              method;
760
761            quantize_info->dither_method=NoDitherMethod;
762            if (*option == '+')
763              break;
764            i++;
765            if (i == (ssize_t) argc)
766              ThrowAnimateException(OptionError,"MissingArgument",option);
767            method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
768            if (method < 0)
769              ThrowAnimateException(OptionError,"UnrecognizedDitherMethod",
770                argv[i]);
771            quantize_info->dither_method=(DitherMethod) method;
772            break;
773          }
774        if (LocaleCompare("duration",option+1) == 0)
775          {
776            if (*option == '+')
777              break;
778            i++;
779            if (i == (ssize_t) argc)
780              ThrowAnimateException(OptionError,"MissingArgument",option);
781            if (IsGeometry(argv[i]) == MagickFalse)
782              ThrowAnimateInvalidArgumentException(option,argv[i]);
783            break;
784          }
785        ThrowAnimateException(OptionError,"UnrecognizedOption",option);
786      }
787      case 'e':
788      {
789        if (LocaleCompare("extract",option+1) == 0)
790          {
791            if (*option == '+')
792              break;
793            i++;
794            if (i == (ssize_t) argc)
795              ThrowAnimateException(OptionError,"MissingArgument",option);
796            if (IsGeometry(argv[i]) == MagickFalse)
797              ThrowAnimateInvalidArgumentException(option,argv[i]);
798            break;
799          }
800        ThrowAnimateException(OptionError,"UnrecognizedOption",option);
801      }
802      case 'f':
803      {
804        if (LocaleCompare("filter",option+1) == 0)
805          {
806            ssize_t
807              filter;
808
809            if (*option == '+')
810              break;
811            i++;
812            if (i == (ssize_t) argc)
813              ThrowAnimateException(OptionError,"MissingArgument",option);
814            filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
815            if (filter < 0)
816              ThrowAnimateException(OptionError,"UnrecognizedImageFilter",
817                argv[i]);
818            break;
819          }
820        if (LocaleCompare("flatten",option+1) == 0)
821          break;
822        if (LocaleCompare("font",option+1) == 0)
823          {
824            if (*option == '+')
825              break;
826            i++;
827            if (i == (ssize_t) argc)
828              ThrowAnimateException(OptionError,"MissingArgument",option);
829            resource_info.font=XGetResourceClass(resource_database,
830              GetClientName(),"font",argv[i]);
831            break;
832          }
833        if (LocaleCompare("foreground",option+1) == 0)
834          {
835            if (*option == '+')
836              break;
837            i++;
838            if (i == (ssize_t) argc)
839              ThrowAnimateException(OptionError,"MissingArgument",option);
840            resource_info.foreground_color=argv[i];
841            break;
842          }
843        if (LocaleCompare("format",option+1) == 0)
844          {
845            if (*option == '+')
846              break;
847            i++;
848            if (i == (ssize_t) argc)
849              ThrowAnimateException(OptionError,"MissingArgument",option);
850            break;
851          }
852        ThrowAnimateException(OptionError,"UnrecognizedOption",option);
853      }
854      case 'g':
855      {
856        if (LocaleCompare("gamma",option+1) == 0)
857          {
858            i++;
859            if (i == (ssize_t) argc)
860              ThrowAnimateException(OptionError,"MissingArgument",option);
861            if (IsGeometry(argv[i]) == MagickFalse)
862              ThrowAnimateInvalidArgumentException(option,argv[i]);
863            break;
864          }
865        if (LocaleCompare("geometry",option+1) == 0)
866          {
867            resource_info.image_geometry=(char *) NULL;
868            if (*option == '+')
869              break;
870            i++;
871            if (i == (ssize_t) argc)
872              ThrowAnimateException(OptionError,"MissingArgument",option);
873            if (IsGeometry(argv[i]) == MagickFalse)
874              ThrowAnimateInvalidArgumentException(option,argv[i]);
875            resource_info.image_geometry=ConstantString(argv[i]);
876            break;
877          }
878        if (LocaleCompare("gravity",option+1) == 0)
879          {
880            ssize_t
881              gravity;
882
883            if (*option == '+')
884              break;
885            i++;
886            if (i == (ssize_t) argc)
887              ThrowAnimateException(OptionError,"MissingArgument",option);
888            gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
889              argv[i]);
890            if (gravity < 0)
891              ThrowAnimateException(OptionError,"UnrecognizedGravityType",
892                argv[i]);
893            break;
894          }
895        ThrowAnimateException(OptionError,"UnrecognizedOption",option);
896      }
897      case 'h':
898      {
899        if ((LocaleCompare("help",option+1) == 0) ||
900            (LocaleCompare("-help",option+1) == 0))
901          break;
902        ThrowAnimateException(OptionError,"UnrecognizedOption",option);
903      }
904      case 'i':
905      {
906        if (LocaleCompare("iconGeometry",option+1) == 0)
907          {
908            resource_info.icon_geometry=(char *) NULL;
909            if (*option == '+')
910              break;
911            i++;
912            if (i == (ssize_t) argc)
913              ThrowAnimateException(OptionError,"MissingArgument",option);
914            if (IsGeometry(argv[i]) == MagickFalse)
915              ThrowAnimateInvalidArgumentException(option,argv[i]);
916            resource_info.icon_geometry=argv[i];
917            break;
918          }
919        if (LocaleCompare("iconic",option+1) == 0)
920          {
921            resource_info.iconic=(*option == '-') ? MagickTrue : MagickFalse;
922            break;
923          }
924        if (LocaleCompare("identify",option+1) == 0)
925          break;
926        if (LocaleCompare("immutable",option+1) == 0)
927          {
928            resource_info.immutable=(*option == '-') ? MagickTrue : MagickFalse;
929            break;
930          }
931        if (LocaleCompare("interlace",option+1) == 0)
932          {
933            ssize_t
934              interlace;
935
936            if (*option == '+')
937              break;
938            i++;
939            if (i == (ssize_t) argc)
940              ThrowAnimateException(OptionError,"MissingArgument",option);
941            interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
942              argv[i]);
943            if (interlace < 0)
944              ThrowAnimateException(OptionError,"UnrecognizedInterlaceType",
945                argv[i]);
946            break;
947          }
948        if (LocaleCompare("interpolate",option+1) == 0)
949          {
950            ssize_t
951              interpolate;
952
953            if (*option == '+')
954              break;
955            i++;
956            if (i == (ssize_t) argc)
957              ThrowAnimateException(OptionError,"MissingArgument",option);
958            interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
959              argv[i]);
960            if (interpolate < 0)
961              ThrowAnimateException(OptionError,"UnrecognizedInterpolateMethod",
962                argv[i]);
963            break;
964          }
965        ThrowAnimateException(OptionError,"UnrecognizedOption",option);
966      }
967      case 'l':
968      {
969        if (LocaleCompare("label",option+1) == 0)
970          {
971            if (*option == '+')
972              break;
973            i++;
974            if (i == (ssize_t) argc)
975              ThrowAnimateException(OptionError,"MissingArgument",option);
976            break;
977          }
978        if (LocaleCompare("limit",option+1) == 0)
979          {
980            char
981              *p;
982
983            double
984              value;
985
986            ssize_t
987              resource;
988
989            if (*option == '+')
990              break;
991            i++;
992            if (i == (ssize_t) argc)
993              ThrowAnimateException(OptionError,"MissingArgument",option);
994            resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
995              argv[i]);
996            if (resource < 0)
997              ThrowAnimateException(OptionError,"UnrecognizedResourceType",
998                argv[i]);
999            i++;
1000            if (i == (ssize_t) argc)
1001              ThrowAnimateException(OptionError,"MissingArgument",option);
1002            value=StringToDouble(argv[i],&p);
1003            (void) value;
1004            if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
1005              ThrowAnimateInvalidArgumentException(option,argv[i]);
1006            break;
1007          }
1008        if (LocaleCompare("list",option+1) == 0)
1009          {
1010            ssize_t
1011              list;
1012
1013            if (*option == '+')
1014              break;
1015            i++;
1016            if (i == (ssize_t) argc)
1017              ThrowAnimateException(OptionError,"MissingArgument",option);
1018            list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
1019            if (list < 0)
1020              ThrowAnimateException(OptionError,"UnrecognizedListType",argv[i]);
1021            status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
1022              argv+j,exception);
1023            DestroyAnimate();
1024            return(status == 0 ? MagickTrue : MagickFalse);
1025          }
1026        if (LocaleCompare("log",option+1) == 0)
1027          {
1028            if (*option == '+')
1029              break;
1030            i++;
1031            if ((i == (ssize_t) argc) ||
1032                (strchr(argv[i],'%') == (char *) NULL))
1033              ThrowAnimateException(OptionError,"MissingArgument",option);
1034            break;
1035          }
1036        if (LocaleCompare("loop",option+1) == 0)
1037          {
1038            if (*option == '+')
1039              break;
1040            i++;
1041            if (i == (ssize_t) argc)
1042              ThrowAnimateException(OptionError,"MissingArgument",option);
1043            if (IsGeometry(argv[i]) == MagickFalse)
1044              ThrowAnimateInvalidArgumentException(option,argv[i]);
1045            break;
1046          }
1047        ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1048      }
1049      case 'm':
1050      {
1051        if (LocaleCompare("map",option+1) == 0)
1052          {
1053            resource_info.map_type=(char *) NULL;
1054            if (*option == '+')
1055              break;
1056            (void) CopyMagickString(argv[i]+1,"san",MagickPathExtent);
1057            i++;
1058            if (i == (ssize_t) argc)
1059              ThrowAnimateException(OptionError,"MissingArgument",option);
1060            resource_info.map_type=argv[i];
1061            break;
1062          }
1063        if (LocaleCompare("matte",option+1) == 0)
1064          break;
1065        if (LocaleCompare("monitor",option+1) == 0)
1066          break;
1067        if (LocaleCompare("monochrome",option+1) == 0)
1068          {
1069            if (*option == '+')
1070              break;
1071            quantize_info->number_colors=2;
1072            quantize_info->colorspace=GRAYColorspace;
1073            break;
1074          }
1075        ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1076      }
1077      case 'n':
1078      {
1079        if (LocaleCompare("name",option+1) == 0)
1080          {
1081            resource_info.name=(char *) NULL;
1082            if (*option == '+')
1083              break;
1084            i++;
1085            if (i == (ssize_t) argc)
1086              ThrowAnimateException(OptionError,"MissingArgument",option);
1087            resource_info.name=ConstantString(argv[i]);
1088            break;
1089          }
1090        if (LocaleCompare("noop",option+1) == 0)
1091          break;
1092        ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1093      }
1094      case 'p':
1095      {
1096        if (LocaleCompare("pause",option+1) == 0)
1097          {
1098            resource_info.pause=0;
1099            if (*option == '+')
1100              break;
1101            i++;
1102            if (i == (ssize_t) argc)
1103              ThrowAnimateException(OptionError,"MissingArgument",option);
1104            if (IsGeometry(argv[i]) == MagickFalse)
1105              ThrowAnimateInvalidArgumentException(option,argv[i]);
1106            resource_info.pause=(unsigned int) StringToUnsignedLong(argv[i]);
1107            break;
1108          }
1109        if (LocaleCompare("page",option+1) == 0)
1110          {
1111            if (*option == '+')
1112              break;
1113            i++;
1114            if (i == (ssize_t) argc)
1115              ThrowAnimateException(OptionError,"MissingArgument",option);
1116            break;
1117          }
1118        if (LocaleCompare("profile",option+1) == 0)
1119          {
1120            i++;
1121            if (i == (ssize_t) argc)
1122              ThrowAnimateException(OptionError,"MissingArgument",option);
1123            break;
1124          }
1125        ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1126      }
1127      case 'q':
1128      {
1129        if (LocaleCompare("quantize",option+1) == 0)
1130          {
1131            ssize_t
1132              colorspace;
1133
1134            if (*option == '+')
1135              break;
1136            i++;
1137            if (i == (ssize_t) argc)
1138              ThrowAnimateException(OptionError,"MissingArgument",option);
1139            colorspace=ParseCommandOption(MagickColorspaceOptions,
1140              MagickFalse,argv[i]);
1141            if (colorspace < 0)
1142              ThrowAnimateException(OptionError,"UnrecognizedColorspace",
1143                argv[i]);
1144            break;
1145          }
1146        if (LocaleCompare("quiet",option+1) == 0)
1147          break;
1148        ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1149      }
1150      case 'r':
1151      {
1152        if (LocaleCompare("regard-warnings",option+1) == 0)
1153          break;
1154        if (LocaleCompare("remote",option+1) == 0)
1155          {
1156            i++;
1157            if (i == (ssize_t) argc)
1158              ThrowAnimateException(OptionError,"MissingArgument",option);
1159            if (XRemoteCommand(display,resource_info.window_id,argv[i]) != 0)
1160              return(MagickFalse);
1161            i--;
1162            break;
1163          }
1164        if (LocaleCompare("repage",option+1) == 0)
1165          {
1166            if (*option == '+')
1167              break;
1168            i++;
1169            if (i == (ssize_t) argc)
1170              ThrowAnimateException(OptionError,"MissingArgument",option);
1171            if (IsGeometry(argv[i]) == MagickFalse)
1172              ThrowAnimateInvalidArgumentException(option,argv[i]);
1173            break;
1174          }
1175        if (LocaleCompare("resample",option+1) == 0)
1176          {
1177            if (*option == '+')
1178              break;
1179            i++;
1180            if (i == (ssize_t) argc)
1181              ThrowAnimateException(OptionError,"MissingArgument",option);
1182            if (IsGeometry(argv[i]) == MagickFalse)
1183              ThrowAnimateInvalidArgumentException(option,argv[i]);
1184            break;
1185          }
1186        if (LocaleCompare("resize",option+1) == 0)
1187          {
1188            if (*option == '+')
1189              break;
1190            i++;
1191            if (i == (ssize_t) argc)
1192              ThrowAnimateException(OptionError,"MissingArgument",option);
1193            if (IsGeometry(argv[i]) == MagickFalse)
1194              ThrowAnimateInvalidArgumentException(option,argv[i]);
1195            break;
1196          }
1197        if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
1198          {
1199            respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
1200            break;
1201          }
1202        if (LocaleCompare("rotate",option+1) == 0)
1203          {
1204            i++;
1205            if (i == (ssize_t) argc)
1206              ThrowAnimateException(OptionError,"MissingArgument",option);
1207            if (IsGeometry(argv[i]) == MagickFalse)
1208              ThrowAnimateInvalidArgumentException(option,argv[i]);
1209            break;
1210          }
1211        ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1212      }
1213      case 's':
1214      {
1215        if (LocaleCompare("sampling-factor",option+1) == 0)
1216          {
1217            if (*option == '+')
1218              break;
1219            i++;
1220            if (i == (ssize_t) argc)
1221              ThrowAnimateException(OptionError,"MissingArgument",option);
1222            if (IsGeometry(argv[i]) == MagickFalse)
1223              ThrowAnimateInvalidArgumentException(option,argv[i]);
1224            break;
1225          }
1226        if (LocaleCompare("seed",option+1) == 0)
1227          {
1228            if (*option == '+')
1229              break;
1230            i++;
1231            if (i == (ssize_t) argc)
1232              ThrowAnimateException(OptionError,"MissingArgument",option);
1233            if (IsGeometry(argv[i]) == MagickFalse)
1234              ThrowAnimateInvalidArgumentException(option,argv[i]);
1235            break;
1236          }
1237        if (LocaleCompare("scenes",option+1) == 0)  /* deprecated */
1238          {
1239            if (*option == '+')
1240              break;
1241            i++;
1242            if (i == (ssize_t) argc)
1243              ThrowAnimateException(OptionError,"MissingArgument",option);
1244            if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
1245              ThrowAnimateInvalidArgumentException(option,argv[i]);
1246            break;
1247          }
1248        if (LocaleCompare("set",option+1) == 0)
1249          {
1250            i++;
1251            if (i == (ssize_t) argc)
1252              ThrowAnimateException(OptionError,"MissingArgument",option);
1253            if (*option == '+')
1254              break;
1255            i++;
1256            if (i == (ssize_t) argc)
1257              ThrowAnimateException(OptionError,"MissingArgument",option);
1258            break;
1259          }
1260        if (LocaleCompare("shared-memory",option+1) == 0)
1261          {
1262            resource_info.use_shared_memory=(*option == '-') ? MagickTrue :
1263              MagickFalse;
1264            break;
1265          }
1266        if (LocaleCompare("size",option+1) == 0)
1267          {
1268            if (*option == '+')
1269              break;
1270            i++;
1271            if (i == (ssize_t) argc)
1272              ThrowAnimateException(OptionError,"MissingArgument",option);
1273            if (IsGeometry(argv[i]) == MagickFalse)
1274              ThrowAnimateInvalidArgumentException(option,argv[i]);
1275            break;
1276          }
1277        if (LocaleCompare("strip",option+1) == 0)
1278          break;
1279        if (LocaleCompare("support",option+1) == 0)
1280          {
1281            i++;  /* deprecated */
1282            break;
1283          }
1284        ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1285      }
1286      case 't':
1287      {
1288        if (LocaleCompare("text-font",option+1) == 0)
1289          {
1290            resource_info.text_font=(char *) NULL;
1291            if (*option == '+')
1292              break;
1293            i++;
1294            if (i == (ssize_t) argc)
1295              ThrowAnimateException(OptionError,"MissingArgument",option);
1296            resource_info.text_font=XGetResourceClass(resource_database,
1297              GetClientName(),"font",argv[i]);
1298            break;
1299          }
1300        if (LocaleCompare("thumbnail",option+1) == 0)
1301          {
1302            if (*option == '+')
1303              break;
1304            i++;
1305            if (i == (ssize_t) argc)
1306              ThrowAnimateException(OptionError,"MissingArgument",option);
1307            if (IsGeometry(argv[i]) == MagickFalse)
1308              ThrowAnimateInvalidArgumentException(option,argv[i]);
1309            break;
1310          }
1311        if (LocaleCompare("title",option+1) == 0)
1312          {
1313            resource_info.title=(char *) NULL;
1314            if (*option == '+')
1315              break;
1316            i++;
1317            if (i == (ssize_t) argc)
1318              ThrowAnimateException(OptionError,"MissingArgument",option);
1319            resource_info.title=argv[i];
1320            break;
1321          }
1322        if (LocaleCompare("transparent-color",option+1) == 0)
1323          {
1324            if (*option == '+')
1325              break;
1326            i++;
1327            if (i == (ssize_t) argc)
1328              ThrowAnimateException(OptionError,"MissingArgument",option);
1329            break;
1330          }
1331        if (LocaleCompare("treedepth",option+1) == 0)
1332          {
1333            quantize_info->tree_depth=0;
1334            if (*option == '+')
1335              break;
1336            i++;
1337            if (i == (ssize_t) argc)
1338              ThrowAnimateException(OptionError,"MissingArgument",option);
1339            if (IsGeometry(argv[i]) == MagickFalse)
1340              ThrowAnimateInvalidArgumentException(option,argv[i]);
1341            quantize_info->tree_depth=StringToUnsignedLong(argv[i]);
1342            break;
1343          }
1344        if (LocaleCompare("trim",option+1) == 0)
1345          break;
1346        ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1347      }
1348      case 'v':
1349      {
1350        if (LocaleCompare("verbose",option+1) == 0)
1351          break;
1352        if ((LocaleCompare("version",option+1) == 0) ||
1353            (LocaleCompare("-version",option+1) == 0))
1354          {
1355            ListMagickVersion(stdout);
1356            break;
1357          }
1358        if (LocaleCompare("virtual-pixel",option+1) == 0)
1359          {
1360            ssize_t
1361              method;
1362
1363            if (*option == '+')
1364              break;
1365            i++;
1366            if (i == (ssize_t) argc)
1367              ThrowAnimateException(OptionError,"MissingArgument",option);
1368            method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
1369              argv[i]);
1370            if (method < 0)
1371              ThrowAnimateException(OptionError,
1372                "UnrecognizedVirtualPixelMethod",argv[i]);
1373            break;
1374          }
1375        if (LocaleCompare("visual",option+1) == 0)
1376          {
1377            resource_info.visual_type=(char *) NULL;
1378            if (*option == '+')
1379              break;
1380            i++;
1381            if (i == (ssize_t) argc)
1382              ThrowAnimateException(OptionError,"MissingArgument",option);
1383            resource_info.visual_type=argv[i];
1384            break;
1385          }
1386        ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1387      }
1388      case 'w':
1389      {
1390        if (LocaleCompare("window",option+1) == 0)
1391          {
1392            resource_info.window_id=(char *) NULL;
1393            if (*option == '+')
1394              break;
1395            i++;
1396            if (i == (ssize_t) argc)
1397              ThrowAnimateException(OptionError,"MissingArgument",option);
1398            resource_info.window_id=argv[i];
1399            break;
1400          }
1401        ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1402      }
1403      case '?':
1404        break;
1405      default:
1406        ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1407    }
1408    fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
1409      FireOptionFlag) == 0 ?  MagickFalse : MagickTrue;
1410    if (fire != MagickFalse)
1411      FireImageStack(MagickFalse,MagickTrue,MagickTrue);
1412  }
1413  i--;
1414  if (k != 0)
1415    ThrowAnimateException(OptionError,"UnbalancedParenthesis",argv[i]);
1416  if (image == (Image *) NULL)
1417    ThrowAnimateException(OptionError,"MissingAnImageFilename",argv[argc-1])
1418  FinalizeImageSettings(image_info,image,MagickTrue);
1419  if (image == (Image *) NULL)
1420    ThrowAnimateException(OptionError,"MissingAnImageFilename",argv[argc-1])
1421  if (resource_info.window_id != (char *) NULL)
1422    {
1423      XAnimateBackgroundImage(display,&resource_info,image,exception);
1424      status&=MagickTrue;
1425    }
1426  else
1427    {
1428      Image
1429        *animate_image;
1430
1431      /*
1432        Animate image to X server.
1433      */
1434      animate_image=XAnimateImages(display,&resource_info,argv,argc,image,
1435        exception);
1436      while (animate_image != (Image *) NULL)
1437      {
1438        image=animate_image;
1439        animate_image=XAnimateImages(display,&resource_info,argv,argc,image,
1440          exception);
1441        if (animate_image != image)
1442          image=DestroyImageList(image);
1443      }
1444    }
1445  DestroyAnimate();
1446  return(status != 0 ? MagickTrue : MagickFalse);
1447#else
1448  (void) argc;
1449  (void) argv;
1450  (void) ThrowMagickException(exception,GetMagickModule(),MissingDelegateError,
1451    "DelegateLibrarySupportNotBuiltIn","'%s' (X11)",image_info->filename);
1452  return(AnimateUsage());
1453#endif
1454}
1455