]> granicus.if.org Git - imagemagick/blob - MagickWand/animate.c
Added checks for exceptions.
[imagemagick] / MagickWand / animate.c
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-2014 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 \f
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 \f
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
93 static 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       "-colors value        preferred number of colors in the image",
116       "-crop geometry       preferred size and location of the cropped image",
117       "-extract geometry    extract area from image",
118       "-monochrome          transform image to black and white",
119       "-repage geometry     size and location of an image canvas (operator)",
120       "-resample geometry   change the resolution of an image",
121       "-resize geometry     resize the image",
122       "-rotate degrees      apply Paeth rotation to the image",
123       "-strip               strip image of all profiles and comments",
124       "-thumbnail geometry  create a thumbnail of the image",
125       "-trim                trim image edges",
126       (char *) NULL
127     },
128     *settings[]=
129     {
130       "-alpha option        on, activate, off, deactivate, set, opaque, copy",
131       "                     transparent, extract, background, or shape",
132       "-authenticate password",
133       "                     decipher image with this password",
134       "-backdrop            display image centered on a backdrop",
135       "-channel type        apply option to select image channels",
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     "-borderwidth, -font, -foreground, -iconGeometry, -iconic, -name,\n");
213   (void) printf("-mattecolor, -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
229 WandExport 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 == MagickSignature);
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(MagickFalse);
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           {
403             int
404               c;
405
406             c=getc(stdin);
407             if (c == EOF)
408               option="logo:";
409             else
410               {
411                 c=ungetc(c,stdin);
412                 option="-";
413               }
414           }
415     if (LocaleCompare(option,"(") == 0)
416       {
417         FireImageStack(MagickFalse,MagickTrue,pend);
418         if (k == MaxImageStackDepth)
419           ThrowAnimateException(OptionError,"ParenthesisNestedTooDeeply",
420             option);
421         PushImageStack();
422         continue;
423       }
424     if (LocaleCompare(option,")") == 0)
425       {
426         FireImageStack(MagickFalse,MagickTrue,MagickTrue);
427         if (k == 0)
428           ThrowAnimateException(OptionError,"UnableToParseExpression",option);
429         PopImageStack();
430         continue;
431       }
432     if (IsCommandOption(option) == MagickFalse)
433       {
434         const char
435           *filename;
436
437         Image
438           *images;
439
440         /*
441           Read input image.
442         */
443         FireImageStack(MagickFalse,MagickFalse,pend);
444         filename=option;
445         if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
446           {
447             option=argv[++i];
448             filename=option;
449           }
450         if (image_info->ping != MagickFalse)
451           images=PingImages(image_info,filename,exception);
452         else
453           images=ReadImages(image_info,filename,exception);
454         status&=(images != (Image *) NULL) &&
455           (exception->severity < ErrorException);
456         if (images == (Image *) NULL)
457           continue;
458         AppendImageStack(images);
459         continue;
460       }
461     pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
462     switch (*(option+1))
463     {
464       case 'a':
465       {
466         if (LocaleCompare("alpha",option+1) == 0)
467           {
468             ssize_t
469               type;
470
471             if (*option == '+')
472               break;
473             i++;
474             if (i == (ssize_t) argc)
475               ThrowAnimateException(OptionError,"MissingArgument",option);
476             type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,argv[i]);
477             if (type < 0)
478               ThrowAnimateException(OptionError,"UnrecognizedAlphaChannelOption",
479                 argv[i]);
480             break;
481           }
482         if (LocaleCompare("authenticate",option+1) == 0)
483           {
484             if (*option == '+')
485               break;
486             i++;
487             if (i == (ssize_t) argc)
488               ThrowAnimateException(OptionError,"MissingArgument",option);
489             break;
490           }
491         ThrowAnimateException(OptionError,"UnrecognizedOption",option);
492       }
493       case 'b':
494       {
495         if (LocaleCompare("backdrop",option+1) == 0)
496           {
497             resource_info.backdrop=(*option == '-') ? MagickTrue : MagickFalse;
498             break;
499           }
500         if (LocaleCompare("background",option+1) == 0)
501           {
502             if (*option == '+')
503               break;
504             i++;
505             if (i == (ssize_t) argc)
506               ThrowAnimateException(OptionError,"MissingArgument",option);
507             resource_info.background_color=argv[i];
508             break;
509           }
510         if (LocaleCompare("bordercolor",option+1) == 0)
511           {
512             if (*option == '+')
513               break;
514             i++;
515             if (i == (ssize_t) argc)
516               ThrowAnimateException(OptionError,"MissingArgument",option);
517             resource_info.border_color=argv[i];
518             break;
519           }
520         if (LocaleCompare("borderwidth",option+1) == 0)
521           {
522             resource_info.border_width=0;
523             if (*option == '+')
524               break;
525             i++;
526             if ((i == (ssize_t) argc) || (IsGeometry(argv[i]) == MagickFalse))
527               ThrowAnimateException(OptionError,"MissingArgument",option);
528             resource_info.border_width=(unsigned int)
529               StringToUnsignedLong(argv[i]);
530             break;
531           }
532         ThrowAnimateException(OptionError,"UnrecognizedOption",option);
533       }
534       case 'c':
535       {
536         if (LocaleCompare("cache",option+1) == 0)
537           {
538             if (*option == '+')
539               break;
540             i++;
541             if (i == (ssize_t) argc)
542               ThrowAnimateException(OptionError,"MissingArgument",option);
543             if (IsGeometry(argv[i]) == MagickFalse)
544               ThrowAnimateInvalidArgumentException(option,argv[i]);
545             break;
546           }
547         if (LocaleCompare("channel",option+1) == 0)
548           {
549             ssize_t
550               channel;
551
552             if (*option == '+')
553               break;
554             i++;
555             if (i == (ssize_t) argc)
556               ThrowAnimateException(OptionError,"MissingArgument",option);
557             channel=ParseChannelOption(argv[i]);
558             if (channel < 0)
559               ThrowAnimateException(OptionError,"UnrecognizedChannelType",
560                 argv[i]);
561             break;
562           }
563         if (LocaleCompare("clone",option+1) == 0)
564           {
565             Image
566               *clone_images;
567
568             clone_images=image;
569             if (k != 0)
570               clone_images=image_stack[k-1].image;
571             if (clone_images == (Image *) NULL)
572               ThrowAnimateException(ImageError,"UnableToCloneImage",option);
573             FireImageStack(MagickFalse,MagickTrue,MagickTrue);
574             if (*option == '+')
575               clone_images=CloneImages(clone_images,"-1",exception);
576             else
577               {
578                 i++;
579                 if (i == (ssize_t) argc)
580                   ThrowAnimateException(OptionError,"MissingArgument",option);
581                 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
582                   ThrowAnimateInvalidArgumentException(option,argv[i]);
583                 clone_images=CloneImages(clone_images,argv[i],exception);
584               }
585             if (clone_images == (Image *) NULL)
586               ThrowAnimateException(OptionError,"NoSuchImage",option);
587             AppendImageStack(clone_images);
588             break;
589           }
590         if (LocaleCompare("coalesce",option+1) == 0)
591           break;
592         if (LocaleCompare("colormap",option+1) == 0)
593           {
594             resource_info.colormap=PrivateColormap;
595             if (*option == '+')
596               break;
597             i++;
598             if (i == (ssize_t) argc)
599               ThrowAnimateException(OptionError,"MissingArgument",option);
600             resource_info.colormap=UndefinedColormap;
601             if (LocaleCompare("private",argv[i]) == 0)
602               resource_info.colormap=PrivateColormap;
603             if (LocaleCompare("shared",argv[i]) == 0)
604               resource_info.colormap=SharedColormap;
605             if (resource_info.colormap == UndefinedColormap)
606               ThrowAnimateException(OptionError,"UnrecognizedColormapType",
607                 argv[i]);
608             break;
609           }
610         if (LocaleCompare("colors",option+1) == 0)
611           {
612             quantize_info->number_colors=0;
613             if (*option == '+')
614               break;
615             i++;
616             if (i == (ssize_t) argc)
617               ThrowAnimateException(OptionError,"MissingArgument",option);
618             if (IsGeometry(argv[i]) == MagickFalse)
619               ThrowAnimateInvalidArgumentException(option,argv[i]);
620             quantize_info->number_colors=StringToUnsignedLong(argv[i]);
621             break;
622           }
623         if (LocaleCompare("colorspace",option+1) == 0)
624           {
625             ssize_t
626               colorspace;
627
628             if (*option == '+')
629               break;
630             i++;
631             if (i == (ssize_t) argc)
632               ThrowAnimateException(OptionError,"MissingArgument",option);
633             colorspace=ParseCommandOption(MagickColorspaceOptions,
634               MagickFalse,argv[i]);
635             if (colorspace < 0)
636               ThrowAnimateException(OptionError,"UnrecognizedColorspace",
637                 argv[i]);
638             break;
639           }
640         if (LocaleCompare("concurrent",option+1) == 0)
641           break;
642         if (LocaleCompare("crop",option+1) == 0)
643           {
644             if (*option == '+')
645               break;
646             i++;
647             if (i == (ssize_t) argc)
648               ThrowAnimateException(OptionError,"MissingArgument",option);
649             if (IsGeometry(argv[i]) == MagickFalse)
650               ThrowAnimateInvalidArgumentException(option,argv[i]);
651             break;
652           }
653         ThrowAnimateException(OptionError,"UnrecognizedOption",option);
654       }
655       case 'd':
656       {
657         if (LocaleCompare("debug",option+1) == 0)
658           {
659             ssize_t
660               event;
661
662             if (*option == '+')
663               break;
664             i++;
665             if (i == (ssize_t) argc)
666               ThrowAnimateException(OptionError,"MissingArgument",option);
667             event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
668             if (event < 0)
669               ThrowAnimateException(OptionError,"UnrecognizedEventType",
670                 argv[i]);
671             (void) SetLogEventMask(argv[i]);
672             break;
673           }
674         if (LocaleCompare("decipher",option+1) == 0)
675           {
676             if (*option == '+')
677               break;
678             i++;
679             if (i == (ssize_t) argc)
680               ThrowAnimateException(OptionError,"MissingArgument",option);
681             break;
682           }
683         if (LocaleCompare("define",option+1) == 0)
684           {
685             i++;
686             if (i == (ssize_t) argc)
687               ThrowAnimateException(OptionError,"MissingArgument",option);
688             if (*option == '+')
689               {
690                 const char
691                   *define;
692
693                 define=GetImageOption(image_info,argv[i]);
694                 if (define == (const char *) NULL)
695                   ThrowAnimateException(OptionError,"NoSuchOption",argv[i]);
696                 break;
697               }
698             break;
699           }
700         if (LocaleCompare("delay",option+1) == 0)
701           {
702             if (*option == '+')
703               break;
704             i++;
705             if (i == (ssize_t) argc)
706               ThrowAnimateException(OptionError,"MissingArgument",option);
707             if (IsGeometry(argv[i]) == MagickFalse)
708               ThrowAnimateInvalidArgumentException(option,argv[i]);
709             break;
710           }
711         if (LocaleCompare("density",option+1) == 0)
712           {
713             if (*option == '+')
714               break;
715             i++;
716             if (i == (ssize_t) argc)
717               ThrowAnimateException(OptionError,"MissingArgument",option);
718             if (IsGeometry(argv[i]) == MagickFalse)
719               ThrowAnimateInvalidArgumentException(option,argv[i]);
720             break;
721           }
722         if (LocaleCompare("depth",option+1) == 0)
723           {
724             if (*option == '+')
725               break;
726             i++;
727             if (i == (ssize_t) argc)
728               ThrowAnimateException(OptionError,"MissingArgument",option);
729             if (IsGeometry(argv[i]) == MagickFalse)
730               ThrowAnimateInvalidArgumentException(option,argv[i]);
731             break;
732           }
733         if (LocaleCompare("display",option+1) == 0)
734           {
735             if (*option == '+')
736               break;
737             i++;
738             if (i == (ssize_t) argc)
739               ThrowAnimateException(OptionError,"MissingArgument",option);
740             break;
741           }
742         if (LocaleCompare("dispose",option+1) == 0)
743           {
744             ssize_t
745               dispose;
746
747             if (*option == '+')
748               break;
749             i++;
750             if (i == (ssize_t) argc)
751               ThrowAnimateException(OptionError,"MissingArgument",option);
752             dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
753             if (dispose < 0)
754               ThrowAnimateException(OptionError,"UnrecognizedDisposeMethod",
755                 argv[i]);
756             break;
757           }
758         if (LocaleCompare("dither",option+1) == 0)
759           {
760             ssize_t
761               method;
762
763             quantize_info->dither_method=NoDitherMethod;
764             if (*option == '+')
765               break;
766             i++;
767             if (i == (ssize_t) argc)
768               ThrowAnimateException(OptionError,"MissingArgument",option);
769             method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
770             if (method < 0)
771               ThrowAnimateException(OptionError,"UnrecognizedDitherMethod",
772                 argv[i]);
773             quantize_info->dither_method=(DitherMethod) method;
774             break;
775           }
776         if (LocaleCompare("duration",option+1) == 0)
777           {
778             if (*option == '+')
779               break;
780             i++;
781             if (i == (ssize_t) argc)
782               ThrowAnimateException(OptionError,"MissingArgument",option);
783             if (IsGeometry(argv[i]) == MagickFalse)
784               ThrowAnimateInvalidArgumentException(option,argv[i]);
785             break;
786           }
787         ThrowAnimateException(OptionError,"UnrecognizedOption",option);
788       }
789       case 'e':
790       {
791         if (LocaleCompare("extract",option+1) == 0)
792           {
793             if (*option == '+')
794               break;
795             i++;
796             if (i == (ssize_t) argc)
797               ThrowAnimateException(OptionError,"MissingArgument",option);
798             if (IsGeometry(argv[i]) == MagickFalse)
799               ThrowAnimateInvalidArgumentException(option,argv[i]);
800             break;
801           }
802         ThrowAnimateException(OptionError,"UnrecognizedOption",option);
803       }
804       case 'f':
805       {
806         if (LocaleCompare("filter",option+1) == 0)
807           {
808             ssize_t
809               filter;
810
811             if (*option == '+')
812               break;
813             i++;
814             if (i == (ssize_t) argc)
815               ThrowAnimateException(OptionError,"MissingArgument",option);
816             filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
817             if (filter < 0)
818               ThrowAnimateException(OptionError,"UnrecognizedImageFilter",
819                 argv[i]);
820             break;
821           }
822         if (LocaleCompare("flatten",option+1) == 0)
823           break;
824         if (LocaleCompare("font",option+1) == 0)
825           {
826             if (*option == '+')
827               break;
828             i++;
829             if (i == (ssize_t) argc)
830               ThrowAnimateException(OptionError,"MissingArgument",option);
831             resource_info.font=XGetResourceClass(resource_database,
832               GetClientName(),"font",argv[i]);
833             break;
834           }
835         if (LocaleCompare("foreground",option+1) == 0)
836           {
837             if (*option == '+')
838               break;
839             i++;
840             if (i == (ssize_t) argc)
841               ThrowAnimateException(OptionError,"MissingArgument",option);
842             resource_info.foreground_color=argv[i];
843             break;
844           }
845         if (LocaleCompare("format",option+1) == 0)
846           {
847             if (*option == '+')
848               break;
849             i++;
850             if (i == (ssize_t) argc)
851               ThrowAnimateException(OptionError,"MissingArgument",option);
852             break;
853           }
854         ThrowAnimateException(OptionError,"UnrecognizedOption",option);
855       }
856       case 'g':
857       {
858         if (LocaleCompare("gamma",option+1) == 0)
859           {
860             i++;
861             if (i == (ssize_t) argc)
862               ThrowAnimateException(OptionError,"MissingArgument",option);
863             if (IsGeometry(argv[i]) == MagickFalse)
864               ThrowAnimateInvalidArgumentException(option,argv[i]);
865             break;
866           }
867         if (LocaleCompare("geometry",option+1) == 0)
868           {
869             resource_info.image_geometry=(char *) NULL;
870             if (*option == '+')
871               break;
872             i++;
873             if (i == (ssize_t) argc)
874               ThrowAnimateException(OptionError,"MissingArgument",option);
875             if (IsGeometry(argv[i]) == MagickFalse)
876               ThrowAnimateInvalidArgumentException(option,argv[i]);
877             resource_info.image_geometry=ConstantString(argv[i]);
878             break;
879           }
880         if (LocaleCompare("gravity",option+1) == 0)
881           {
882             ssize_t
883               gravity;
884
885             if (*option == '+')
886               break;
887             i++;
888             if (i == (ssize_t) argc)
889               ThrowAnimateException(OptionError,"MissingArgument",option);
890             gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
891               argv[i]);
892             if (gravity < 0)
893               ThrowAnimateException(OptionError,"UnrecognizedGravityType",
894                 argv[i]);
895             break;
896           }
897         ThrowAnimateException(OptionError,"UnrecognizedOption",option);
898       }
899       case 'h':
900       {
901         if ((LocaleCompare("help",option+1) == 0) ||
902             (LocaleCompare("-help",option+1) == 0))
903           break;
904         ThrowAnimateException(OptionError,"UnrecognizedOption",option);
905       }
906       case 'i':
907       {
908         if (LocaleCompare("iconGeometry",option+1) == 0)
909           {
910             resource_info.icon_geometry=(char *) NULL;
911             if (*option == '+')
912               break;
913             i++;
914             if (i == (ssize_t) argc)
915               ThrowAnimateException(OptionError,"MissingArgument",option);
916             if (IsGeometry(argv[i]) == MagickFalse)
917               ThrowAnimateInvalidArgumentException(option,argv[i]);
918             resource_info.icon_geometry=argv[i];
919             break;
920           }
921         if (LocaleCompare("iconic",option+1) == 0)
922           {
923             resource_info.iconic=(*option == '-') ? MagickTrue : MagickFalse;
924             break;
925           }
926         if (LocaleCompare("identify",option+1) == 0)
927           break;
928         if (LocaleCompare("immutable",option+1) == 0)
929           {
930             resource_info.immutable=(*option == '-') ? MagickTrue : MagickFalse;
931             break;
932           }
933         if (LocaleCompare("interlace",option+1) == 0)
934           {
935             ssize_t
936               interlace;
937
938             if (*option == '+')
939               break;
940             i++;
941             if (i == (ssize_t) argc)
942               ThrowAnimateException(OptionError,"MissingArgument",option);
943             interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
944               argv[i]);
945             if (interlace < 0)
946               ThrowAnimateException(OptionError,"UnrecognizedInterlaceType",
947                 argv[i]);
948             break;
949           }
950         if (LocaleCompare("interpolate",option+1) == 0)
951           {
952             ssize_t
953               interpolate;
954
955             if (*option == '+')
956               break;
957             i++;
958             if (i == (ssize_t) argc)
959               ThrowAnimateException(OptionError,"MissingArgument",option);
960             interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
961               argv[i]);
962             if (interpolate < 0)
963               ThrowAnimateException(OptionError,"UnrecognizedInterpolateMethod",
964                 argv[i]);
965             break;
966           }
967         ThrowAnimateException(OptionError,"UnrecognizedOption",option);
968       }
969       case 'l':
970       {
971         if (LocaleCompare("label",option+1) == 0)
972           {
973             if (*option == '+')
974               break;
975             i++;
976             if (i == (ssize_t) argc)
977               ThrowAnimateException(OptionError,"MissingArgument",option);
978             break;
979           }
980         if (LocaleCompare("limit",option+1) == 0)
981           {
982             char
983               *p;
984
985             double
986               value;
987
988             ssize_t
989               resource;
990
991             if (*option == '+')
992               break;
993             i++;
994             if (i == (ssize_t) argc)
995               ThrowAnimateException(OptionError,"MissingArgument",option);
996             resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
997               argv[i]);
998             if (resource < 0)
999               ThrowAnimateException(OptionError,"UnrecognizedResourceType",
1000                 argv[i]);
1001             i++;
1002             if (i == (ssize_t) argc)
1003               ThrowAnimateException(OptionError,"MissingArgument",option);
1004             value=StringToDouble(argv[i],&p);
1005             (void) value;
1006             if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
1007               ThrowAnimateInvalidArgumentException(option,argv[i]);
1008             break;
1009           }
1010         if (LocaleCompare("list",option+1) == 0)
1011           {
1012             ssize_t
1013               list;
1014
1015             if (*option == '+')
1016               break;
1017             i++;
1018             if (i == (ssize_t) argc)
1019               ThrowAnimateException(OptionError,"MissingArgument",option);
1020             list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
1021             if (list < 0)
1022               ThrowAnimateException(OptionError,"UnrecognizedListType",argv[i]);
1023             status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
1024               argv+j,exception);
1025             DestroyAnimate();
1026             return(status != 0 ? MagickFalse : MagickTrue);
1027           }
1028         if (LocaleCompare("log",option+1) == 0)
1029           {
1030             if (*option == '+')
1031               break;
1032             i++;
1033             if ((i == (ssize_t) argc) ||
1034                 (strchr(argv[i],'%') == (char *) NULL))
1035               ThrowAnimateException(OptionError,"MissingArgument",option);
1036             break;
1037           }
1038         if (LocaleCompare("loop",option+1) == 0)
1039           {
1040             if (*option == '+')
1041               break;
1042             i++;
1043             if (i == (ssize_t) argc)
1044               ThrowAnimateException(OptionError,"MissingArgument",option);
1045             if (IsGeometry(argv[i]) == MagickFalse)
1046               ThrowAnimateInvalidArgumentException(option,argv[i]);
1047             break;
1048           }
1049         ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1050       }
1051       case 'm':
1052       {
1053         if (LocaleCompare("map",option+1) == 0)
1054           {
1055             resource_info.map_type=(char *) NULL;
1056             if (*option == '+')
1057               break;
1058             (void) CopyMagickString(argv[i]+1,"san",MaxTextExtent);
1059             i++;
1060             if (i == (ssize_t) argc)
1061               ThrowAnimateException(OptionError,"MissingArgument",option);
1062             resource_info.map_type=argv[i];
1063             break;
1064           }
1065         if (LocaleCompare("matte",option+1) == 0)
1066           break;
1067         if (LocaleCompare("mattecolor",option+1) == 0)
1068           {
1069             if (*option == '+')
1070               break;
1071             i++;
1072             if (i == (ssize_t) argc)
1073               ThrowAnimateException(OptionError,"MissingArgument",option);
1074             resource_info.matte_color=argv[i];
1075             break;
1076           }
1077         if (LocaleCompare("monitor",option+1) == 0)
1078           break;
1079         if (LocaleCompare("monochrome",option+1) == 0)
1080           {
1081             if (*option == '+')
1082               break;
1083             quantize_info->number_colors=2;
1084             quantize_info->colorspace=GRAYColorspace;
1085             break;
1086           }
1087         ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1088       }
1089       case 'n':
1090       {
1091         if (LocaleCompare("name",option+1) == 0)
1092           {
1093             resource_info.name=(char *) NULL;
1094             if (*option == '+')
1095               break;
1096             i++;
1097             if (i == (ssize_t) argc)
1098               ThrowAnimateException(OptionError,"MissingArgument",option);
1099             resource_info.name=ConstantString(argv[i]);
1100             break;
1101           }
1102         if (LocaleCompare("noop",option+1) == 0)
1103           break;
1104         ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1105       }
1106       case 'p':
1107       {
1108         if (LocaleCompare("pause",option+1) == 0)
1109           {
1110             resource_info.pause=0;
1111             if (*option == '+')
1112               break;
1113             i++;
1114             if (i == (ssize_t) argc)
1115               ThrowAnimateException(OptionError,"MissingArgument",option);
1116             if (IsGeometry(argv[i]) == MagickFalse)
1117               ThrowAnimateInvalidArgumentException(option,argv[i]);
1118             resource_info.pause=(unsigned int) StringToUnsignedLong(argv[i]);
1119             break;
1120           }
1121         if (LocaleCompare("page",option+1) == 0)
1122           {
1123             if (*option == '+')
1124               break;
1125             i++;
1126             if (i == (ssize_t) argc)
1127               ThrowAnimateException(OptionError,"MissingArgument",option);
1128             break;
1129           }
1130         if (LocaleCompare("profile",option+1) == 0)
1131           {
1132             i++;
1133             if (i == (ssize_t) argc)
1134               ThrowAnimateException(OptionError,"MissingArgument",option);
1135             break;
1136           }
1137         ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1138       }
1139       case 'q':
1140       {
1141         if (LocaleCompare("quantize",option+1) == 0)
1142           {
1143             ssize_t
1144               colorspace;
1145
1146             if (*option == '+')
1147               break;
1148             i++;
1149             if (i == (ssize_t) argc)
1150               ThrowAnimateException(OptionError,"MissingArgument",option);
1151             colorspace=ParseCommandOption(MagickColorspaceOptions,
1152               MagickFalse,argv[i]);
1153             if (colorspace < 0)
1154               ThrowAnimateException(OptionError,"UnrecognizedColorspace",
1155                 argv[i]);
1156             break;
1157           }
1158         if (LocaleCompare("quiet",option+1) == 0)
1159           break;
1160         ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1161       }
1162       case 'r':
1163       {
1164         if (LocaleCompare("regard-warnings",option+1) == 0)
1165           break;
1166         if (LocaleCompare("remote",option+1) == 0)
1167           {
1168             i++;
1169             if (i == (ssize_t) argc)
1170               ThrowAnimateException(OptionError,"MissingArgument",option);
1171             if (XRemoteCommand(display,resource_info.window_id,argv[i]) != 0)
1172               return(MagickFalse);
1173             i--;
1174             break;
1175           }
1176         if (LocaleCompare("repage",option+1) == 0)
1177           {
1178             if (*option == '+')
1179               break;
1180             i++;
1181             if (i == (ssize_t) argc)
1182               ThrowAnimateException(OptionError,"MissingArgument",option);
1183             if (IsGeometry(argv[i]) == MagickFalse)
1184               ThrowAnimateInvalidArgumentException(option,argv[i]);
1185             break;
1186           }
1187         if (LocaleCompare("resample",option+1) == 0)
1188           {
1189             if (*option == '+')
1190               break;
1191             i++;
1192             if (i == (ssize_t) argc)
1193               ThrowAnimateException(OptionError,"MissingArgument",option);
1194             if (IsGeometry(argv[i]) == MagickFalse)
1195               ThrowAnimateInvalidArgumentException(option,argv[i]);
1196             break;
1197           }
1198         if (LocaleCompare("resize",option+1) == 0)
1199           {
1200             if (*option == '+')
1201               break;
1202             i++;
1203             if (i == (ssize_t) argc)
1204               ThrowAnimateException(OptionError,"MissingArgument",option);
1205             if (IsGeometry(argv[i]) == MagickFalse)
1206               ThrowAnimateInvalidArgumentException(option,argv[i]);
1207             break;
1208           }
1209         if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
1210           {
1211             respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
1212             break;
1213           }
1214         if (LocaleCompare("rotate",option+1) == 0)
1215           {
1216             i++;
1217             if (i == (ssize_t) argc)
1218               ThrowAnimateException(OptionError,"MissingArgument",option);
1219             if (IsGeometry(argv[i]) == MagickFalse)
1220               ThrowAnimateInvalidArgumentException(option,argv[i]);
1221             break;
1222           }
1223         ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1224       }
1225       case 's':
1226       {
1227         if (LocaleCompare("sampling-factor",option+1) == 0)
1228           {
1229             if (*option == '+')
1230               break;
1231             i++;
1232             if (i == (ssize_t) argc)
1233               ThrowAnimateException(OptionError,"MissingArgument",option);
1234             if (IsGeometry(argv[i]) == MagickFalse)
1235               ThrowAnimateInvalidArgumentException(option,argv[i]);
1236             break;
1237           }
1238         if (LocaleCompare("seed",option+1) == 0)
1239           {
1240             if (*option == '+')
1241               break;
1242             i++;
1243             if (i == (ssize_t) argc)
1244               ThrowAnimateException(OptionError,"MissingArgument",option);
1245             if (IsGeometry(argv[i]) == MagickFalse)
1246               ThrowAnimateInvalidArgumentException(option,argv[i]);
1247             break;
1248           }
1249         if (LocaleCompare("scenes",option+1) == 0)  /* deprecated */
1250           {
1251             if (*option == '+')
1252               break;
1253             i++;
1254             if (i == (ssize_t) argc)
1255               ThrowAnimateException(OptionError,"MissingArgument",option);
1256             if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
1257               ThrowAnimateInvalidArgumentException(option,argv[i]);
1258             break;
1259           }
1260         if (LocaleCompare("set",option+1) == 0)
1261           {
1262             i++;
1263             if (i == (ssize_t) argc)
1264               ThrowAnimateException(OptionError,"MissingArgument",option);
1265             if (*option == '+')
1266               break;
1267             i++;
1268             if (i == (ssize_t) argc)
1269               ThrowAnimateException(OptionError,"MissingArgument",option);
1270             break;
1271           }
1272         if (LocaleCompare("shared-memory",option+1) == 0)
1273           {
1274             resource_info.use_shared_memory=(*option == '-') ? MagickTrue :
1275               MagickFalse;
1276             break;
1277           }
1278         if (LocaleCompare("size",option+1) == 0)
1279           {
1280             if (*option == '+')
1281               break;
1282             i++;
1283             if (i == (ssize_t) argc)
1284               ThrowAnimateException(OptionError,"MissingArgument",option);
1285             if (IsGeometry(argv[i]) == MagickFalse)
1286               ThrowAnimateInvalidArgumentException(option,argv[i]);
1287             break;
1288           }
1289         if (LocaleCompare("strip",option+1) == 0)
1290           break;
1291         if (LocaleCompare("support",option+1) == 0)
1292           {
1293             i++;  /* deprecated */
1294             break;
1295           }
1296         ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1297       }
1298       case 't':
1299       {
1300         if (LocaleCompare("text-font",option+1) == 0)
1301           {
1302             resource_info.text_font=(char *) NULL;
1303             if (*option == '+')
1304               break;
1305             i++;
1306             if (i == (ssize_t) argc)
1307               ThrowAnimateException(OptionError,"MissingArgument",option);
1308             resource_info.text_font=XGetResourceClass(resource_database,
1309               GetClientName(),"font",argv[i]);
1310             break;
1311           }
1312         if (LocaleCompare("thumbnail",option+1) == 0)
1313           {
1314             if (*option == '+')
1315               break;
1316             i++;
1317             if (i == (ssize_t) argc)
1318               ThrowAnimateException(OptionError,"MissingArgument",option);
1319             if (IsGeometry(argv[i]) == MagickFalse)
1320               ThrowAnimateInvalidArgumentException(option,argv[i]);
1321             break;
1322           }
1323         if (LocaleCompare("title",option+1) == 0)
1324           {
1325             resource_info.title=(char *) NULL;
1326             if (*option == '+')
1327               break;
1328             i++;
1329             if (i == (ssize_t) argc)
1330               ThrowAnimateException(OptionError,"MissingArgument",option);
1331             resource_info.title=argv[i];
1332             break;
1333           }
1334         if (LocaleCompare("transparent-color",option+1) == 0)
1335           {
1336             if (*option == '+')
1337               break;
1338             i++;
1339             if (i == (ssize_t) argc)
1340               ThrowAnimateException(OptionError,"MissingArgument",option);
1341             break;
1342           }
1343         if (LocaleCompare("treedepth",option+1) == 0)
1344           {
1345             quantize_info->tree_depth=0;
1346             if (*option == '+')
1347               break;
1348             i++;
1349             if (i == (ssize_t) argc)
1350               ThrowAnimateException(OptionError,"MissingArgument",option);
1351             if (IsGeometry(argv[i]) == MagickFalse)
1352               ThrowAnimateInvalidArgumentException(option,argv[i]);
1353             quantize_info->tree_depth=StringToUnsignedLong(argv[i]);
1354             break;
1355           }
1356         if (LocaleCompare("trim",option+1) == 0)
1357           break;
1358         ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1359       }
1360       case 'v':
1361       {
1362         if (LocaleCompare("verbose",option+1) == 0)
1363           break;
1364         if ((LocaleCompare("version",option+1) == 0) ||
1365             (LocaleCompare("-version",option+1) == 0))
1366           {
1367             ListMagickVersion(stdout);
1368             break;
1369           }
1370         if (LocaleCompare("virtual-pixel",option+1) == 0)
1371           {
1372             ssize_t
1373               method;
1374
1375             if (*option == '+')
1376               break;
1377             i++;
1378             if (i == (ssize_t) argc)
1379               ThrowAnimateException(OptionError,"MissingArgument",option);
1380             method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
1381               argv[i]);
1382             if (method < 0)
1383               ThrowAnimateException(OptionError,
1384                 "UnrecognizedVirtualPixelMethod",argv[i]);
1385             break;
1386           }
1387         if (LocaleCompare("visual",option+1) == 0)
1388           {
1389             resource_info.visual_type=(char *) NULL;
1390             if (*option == '+')
1391               break;
1392             i++;
1393             if (i == (ssize_t) argc)
1394               ThrowAnimateException(OptionError,"MissingArgument",option);
1395             resource_info.visual_type=argv[i];
1396             break;
1397           }
1398         ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1399       }
1400       case 'w':
1401       {
1402         if (LocaleCompare("window",option+1) == 0)
1403           {
1404             resource_info.window_id=(char *) NULL;
1405             if (*option == '+')
1406               break;
1407             i++;
1408             if (i == (ssize_t) argc)
1409               ThrowAnimateException(OptionError,"MissingArgument",option);
1410             resource_info.window_id=argv[i];
1411             break;
1412           }
1413         ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1414       }
1415       case '?':
1416         break;
1417       default:
1418         ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1419     }
1420     fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
1421       FireOptionFlag) == 0 ?  MagickFalse : MagickTrue;
1422     if (fire != MagickFalse)
1423       FireImageStack(MagickFalse,MagickTrue,MagickTrue);
1424   }
1425   i--;
1426   if (k != 0)
1427     ThrowAnimateException(OptionError,"UnbalancedParenthesis",argv[i]);
1428   if (image == (Image *) NULL)
1429     ThrowAnimateException(OptionError,"MissingAnImageFilename",argv[argc-1])
1430   FinalizeImageSettings(image_info,image,MagickTrue);
1431   if (image == (Image *) NULL)
1432     ThrowAnimateException(OptionError,"MissingAnImageFilename",argv[argc-1])
1433   if (resource_info.window_id != (char *) NULL)
1434     {
1435       XAnimateBackgroundImage(display,&resource_info,image,exception);
1436       status&=MagickTrue;
1437     }
1438   else
1439     {
1440       Image
1441         *animate_image;
1442
1443       /*
1444         Animate image to X server.
1445       */
1446       animate_image=XAnimateImages(display,&resource_info,argv,argc,image,
1447         exception);
1448       status&=animate_image != (Image *) NULL;
1449       while (animate_image != (Image *) NULL)
1450       {
1451         image=animate_image;
1452         animate_image=XAnimateImages(display,&resource_info,argv,argc,image,
1453           exception);
1454         if (animate_image != image)
1455           image=DestroyImageList(image);
1456       }
1457     }
1458   DestroyAnimate();
1459   return(status != 0 ? MagickTrue : MagickFalse);
1460 #else
1461   (void) argc;
1462   (void) argv;
1463   (void) ThrowMagickException(exception,GetMagickModule(),MissingDelegateError,
1464     "DelegateLibrarySupportNotBuiltIn","'%s' (X11)",image_info->filename);
1465   return(AnimateUsage());
1466 #endif
1467 }