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