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