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