]> 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-2012 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-feature.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=IsMagickTrue(resource_value);
390   resource_value=XGetResourceInstance(resource_database,GetClientName(),
391     "dither","True");
392   quantize_info->dither=IsMagickTrue(resource_value);
393   /*
394     Parse command line.
395   */
396   for (i=1; i <= (ssize_t) argc; i++)
397   {
398     if (i < (ssize_t) argc)
399       option=argv[i];
400     else
401       if (image != (Image *) NULL)
402         break;
403       else
404         if (isatty(STDIN_FILENO) != MagickFalse)
405           option="logo:";
406         else
407           {
408             int
409               c;
410
411             c=getc(stdin);
412             if (c == EOF)
413               option="logo:";
414             else
415               {
416                 c=ungetc(c,stdin);
417                 option="-";
418               }
419           }
420     if (LocaleCompare(option,"(") == 0)
421       {
422         FireImageStack(MagickFalse,MagickTrue,pend);
423         if (k == MaxImageStackDepth)
424           ThrowAnimateException(OptionError,"ParenthesisNestedTooDeeply",
425             option);
426         PushImageStack();
427         continue;
428       }
429     if (LocaleCompare(option,")") == 0)
430       {
431         FireImageStack(MagickFalse,MagickTrue,MagickTrue);
432         if (k == 0)
433           ThrowAnimateException(OptionError,"UnableToParseExpression",option);
434         PopImageStack();
435         continue;
436       }
437     if (IsCommandOption(option) == MagickFalse)
438       {
439         const char
440           *filename;
441
442         Image
443           *images;
444
445         /*
446           Read input image.
447         */
448         FireImageStack(MagickFalse,MagickFalse,pend);
449         filename=option;
450         if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
451           {
452             option=argv[++i];
453             filename=option;
454           }
455         (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
456         if (image_info->ping != MagickFalse)
457           images=PingImages(image_info,exception);
458         else
459           images=ReadImages(image_info,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(MagickAlphaOptions,MagickFalse,argv[i]);
483             if (type < 0)
484               ThrowAnimateException(OptionError,"UnrecognizedAlphaChannelType",
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,"ImageSequenceRequired",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=MagickFalse;
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=MagickTrue;
780             quantize_info->dither_method=(DitherMethod) method;
781             break;
782           }
783         if (LocaleCompare("duration",option+1) == 0)
784           {
785             if (*option == '+')
786               break;
787             i++;
788             if (i == (ssize_t) (argc-1))
789               ThrowAnimateException(OptionError,"MissingArgument",option);
790             if (IsGeometry(argv[i]) == MagickFalse)
791               ThrowAnimateInvalidArgumentException(option,argv[i]);
792             break;
793           }
794         ThrowAnimateException(OptionError,"UnrecognizedOption",option);
795       }
796       case 'e':
797       {
798         if (LocaleCompare("extract",option+1) == 0)
799           {
800             if (*option == '+')
801               break;
802             i++;
803             if (i == (ssize_t) argc)
804               ThrowAnimateException(OptionError,"MissingArgument",option);
805             if (IsGeometry(argv[i]) == MagickFalse)
806               ThrowAnimateInvalidArgumentException(option,argv[i]);
807             break;
808           }
809         ThrowAnimateException(OptionError,"UnrecognizedOption",option);
810       }
811       case 'f':
812       {
813         if (LocaleCompare("filter",option+1) == 0)
814           {
815             ssize_t
816               filter;
817
818             if (*option == '+')
819               break;
820             i++;
821             if (i == (ssize_t) (argc-1))
822               ThrowAnimateException(OptionError,"MissingArgument",option);
823             filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
824             if (filter < 0)
825               ThrowAnimateException(OptionError,"UnrecognizedImageFilter",
826                 argv[i]);
827             break;
828           }
829         if (LocaleCompare("flatten",option+1) == 0)
830           break;
831         if (LocaleCompare("font",option+1) == 0)
832           {
833             if (*option == '+')
834               break;
835             i++;
836             if (i == (ssize_t) argc)
837               ThrowAnimateException(OptionError,"MissingArgument",option);
838             resource_info.font=XGetResourceClass(resource_database,
839               GetClientName(),"font",argv[i]);
840             break;
841           }
842         if (LocaleCompare("foreground",option+1) == 0)
843           {
844             if (*option == '+')
845               break;
846             i++;
847             if (i == (ssize_t) argc)
848               ThrowAnimateException(OptionError,"MissingArgument",option);
849             resource_info.foreground_color=argv[i];
850             break;
851           }
852         if (LocaleCompare("format",option+1) == 0)
853           {
854             if (*option == '+')
855               break;
856             i++;
857             if (i == (ssize_t) (argc-1))
858               ThrowAnimateException(OptionError,"MissingArgument",option);
859             break;
860           }
861         ThrowAnimateException(OptionError,"UnrecognizedOption",option);
862       }
863       case 'g':
864       {
865         if (LocaleCompare("gamma",option+1) == 0)
866           {
867             i++;
868             if (i == (ssize_t) argc)
869               ThrowAnimateException(OptionError,"MissingArgument",option);
870             if (IsGeometry(argv[i]) == MagickFalse)
871               ThrowAnimateInvalidArgumentException(option,argv[i]);
872             break;
873           }
874         if (LocaleCompare("geometry",option+1) == 0)
875           {
876             resource_info.image_geometry=(char *) NULL;
877             if (*option == '+')
878               break;
879             i++;
880             if (i == (ssize_t) argc)
881               ThrowAnimateException(OptionError,"MissingArgument",option);
882             if (IsGeometry(argv[i]) == MagickFalse)
883               ThrowAnimateInvalidArgumentException(option,argv[i]);
884             resource_info.image_geometry=ConstantString(argv[i]);
885             break;
886           }
887         if (LocaleCompare("gravity",option+1) == 0)
888           {
889             ssize_t
890               gravity;
891
892             if (*option == '+')
893               break;
894             i++;
895             if (i == (ssize_t) (argc-1))
896               ThrowAnimateException(OptionError,"MissingArgument",option);
897             gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
898               argv[i]);
899             if (gravity < 0)
900               ThrowAnimateException(OptionError,"UnrecognizedGravityType",
901                 argv[i]);
902             break;
903           }
904         ThrowAnimateException(OptionError,"UnrecognizedOption",option);
905       }
906       case 'h':
907       {
908         if ((LocaleCompare("help",option+1) == 0) ||
909             (LocaleCompare("-help",option+1) == 0))
910           break;
911         ThrowAnimateException(OptionError,"UnrecognizedOption",option);
912       }
913       case 'i':
914       {
915         if (LocaleCompare("iconGeometry",option+1) == 0)
916           {
917             resource_info.icon_geometry=(char *) NULL;
918             if (*option == '+')
919               break;
920             i++;
921             if (i == (ssize_t) argc)
922               ThrowAnimateException(OptionError,"MissingArgument",option);
923             if (IsGeometry(argv[i]) == MagickFalse)
924               ThrowAnimateInvalidArgumentException(option,argv[i]);
925             resource_info.icon_geometry=argv[i];
926             break;
927           }
928         if (LocaleCompare("iconic",option+1) == 0)
929           {
930             resource_info.iconic=(*option == '-') ? MagickTrue : MagickFalse;
931             break;
932           }
933         if (LocaleCompare("identify",option+1) == 0)
934           break;
935         if (LocaleCompare("immutable",option+1) == 0)
936           {
937             resource_info.immutable=(*option == '-') ? MagickTrue : MagickFalse;
938             break;
939           }
940         if (LocaleCompare("interlace",option+1) == 0)
941           {
942             ssize_t
943               interlace;
944
945             if (*option == '+')
946               break;
947             i++;
948             if (i == (ssize_t) argc)
949               ThrowAnimateException(OptionError,"MissingArgument",option);
950             interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
951               argv[i]);
952             if (interlace < 0)
953               ThrowAnimateException(OptionError,"UnrecognizedInterlaceType",
954                 argv[i]);
955             break;
956           }
957         if (LocaleCompare("interpolate",option+1) == 0)
958           {
959             ssize_t
960               interpolate;
961
962             if (*option == '+')
963               break;
964             i++;
965             if (i == (ssize_t) argc)
966               ThrowAnimateException(OptionError,"MissingArgument",option);
967             interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
968               argv[i]);
969             if (interpolate < 0)
970               ThrowAnimateException(OptionError,"UnrecognizedInterpolateMethod",
971                 argv[i]);
972             break;
973           }
974         ThrowAnimateException(OptionError,"UnrecognizedOption",option);
975       }
976       case 'l':
977       {
978         if (LocaleCompare("label",option+1) == 0)
979           {
980             if (*option == '+')
981               break;
982             i++;
983             if (i == (ssize_t) argc)
984               ThrowAnimateException(OptionError,"MissingArgument",option);
985             break;
986           }
987         if (LocaleCompare("limit",option+1) == 0)
988           {
989             char
990               *p;
991
992             double
993               value;
994
995             ssize_t
996               resource;
997
998             if (*option == '+')
999               break;
1000             i++;
1001             if (i == (ssize_t) argc)
1002               ThrowAnimateException(OptionError,"MissingArgument",option);
1003             resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
1004               argv[i]);
1005             if (resource < 0)
1006               ThrowAnimateException(OptionError,"UnrecognizedResourceType",
1007                 argv[i]);
1008             i++;
1009             if (i == (ssize_t) argc)
1010               ThrowAnimateException(OptionError,"MissingArgument",option);
1011             value=StringToDouble(argv[i],&p);
1012             (void) value;
1013             if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
1014               ThrowAnimateInvalidArgumentException(option,argv[i]);
1015             break;
1016           }
1017         if (LocaleCompare("list",option+1) == 0)
1018           {
1019             ssize_t
1020               list;
1021
1022             if (*option == '+')
1023               break;
1024             i++;
1025             if (i == (ssize_t) argc)
1026               ThrowAnimateException(OptionError,"MissingArgument",option);
1027             list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
1028             if (list < 0)
1029               ThrowAnimateException(OptionError,"UnrecognizedListType",argv[i]);
1030             status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
1031               argv+j,exception);
1032             DestroyAnimate();
1033             return(status != 0 ? MagickFalse : MagickTrue);
1034           }
1035         if (LocaleCompare("log",option+1) == 0)
1036           {
1037             if (*option == '+')
1038               break;
1039             i++;
1040             if ((i == (ssize_t) argc) ||
1041                 (strchr(argv[i],'%') == (char *) NULL))
1042               ThrowAnimateException(OptionError,"MissingArgument",option);
1043             break;
1044           }
1045         if (LocaleCompare("loop",option+1) == 0)
1046           {
1047             if (*option == '+')
1048               break;
1049             i++;
1050             if (i == (ssize_t) (argc-1))
1051               ThrowAnimateException(OptionError,"MissingArgument",option);
1052             if (IsGeometry(argv[i]) == MagickFalse)
1053               ThrowAnimateInvalidArgumentException(option,argv[i]);
1054             break;
1055           }
1056         ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1057       }
1058       case 'm':
1059       {
1060         if (LocaleCompare("map",option+1) == 0)
1061           {
1062             resource_info.map_type=(char *) NULL;
1063             if (*option == '+')
1064               break;
1065             (void) CopyMagickString(argv[i]+1,"san",MaxTextExtent);
1066             i++;
1067             if (i == (ssize_t) argc)
1068               ThrowAnimateException(OptionError,"MissingArgument",option);
1069             resource_info.map_type=argv[i];
1070             break;
1071           }
1072         if (LocaleCompare("matte",option+1) == 0)
1073           break;
1074         if (LocaleCompare("mattecolor",option+1) == 0)
1075           {
1076             if (*option == '+')
1077               break;
1078             i++;
1079             if (i == (ssize_t) argc)
1080               ThrowAnimateException(OptionError,"MissingArgument",option);
1081             resource_info.matte_color=argv[i];
1082             break;
1083           }
1084         if (LocaleCompare("monitor",option+1) == 0)
1085           break;
1086         if (LocaleCompare("monochrome",option+1) == 0)
1087           {
1088             if (*option == '+')
1089               break;
1090             quantize_info->number_colors=2;
1091             quantize_info->colorspace=GRAYColorspace;
1092             break;
1093           }
1094         ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1095       }
1096       case 'n':
1097       {
1098         if (LocaleCompare("name",option+1) == 0)
1099           {
1100             resource_info.name=(char *) NULL;
1101             if (*option == '+')
1102               break;
1103             i++;
1104             if (i == (ssize_t) argc)
1105               ThrowAnimateException(OptionError,"MissingArgument",option);
1106             resource_info.name=ConstantString(argv[i]);
1107             break;
1108           }
1109         if (LocaleCompare("noop",option+1) == 0)
1110           break;
1111         ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1112       }
1113       case 'p':
1114       {
1115         if (LocaleCompare("pause",option+1) == 0)
1116           {
1117             resource_info.pause=0;
1118             if (*option == '+')
1119               break;
1120             i++;
1121             if (i == (ssize_t) argc)
1122               ThrowAnimateException(OptionError,"MissingArgument",option);
1123             if (IsGeometry(argv[i]) == MagickFalse)
1124               ThrowAnimateInvalidArgumentException(option,argv[i]);
1125             resource_info.pause=(unsigned int) StringToUnsignedLong(argv[i]);
1126             break;
1127           }
1128         if (LocaleCompare("page",option+1) == 0)
1129           {
1130             if (*option == '+')
1131               break;
1132             i++;
1133             if (i == (ssize_t) argc)
1134               ThrowAnimateException(OptionError,"MissingArgument",option);
1135             break;
1136           }
1137         if (LocaleCompare("profile",option+1) == 0)
1138           {
1139             i++;
1140             if (i == (ssize_t) argc)
1141               ThrowAnimateException(OptionError,"MissingArgument",option);
1142             break;
1143           }
1144         ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1145       }
1146       case 'q':
1147       {
1148         if (LocaleCompare("quantize",option+1) == 0)
1149           {
1150             ssize_t
1151               colorspace;
1152
1153             if (*option == '+')
1154               break;
1155             i++;
1156             if (i == (ssize_t) (argc-1))
1157               ThrowAnimateException(OptionError,"MissingArgument",option);
1158             colorspace=ParseCommandOption(MagickColorspaceOptions,
1159               MagickFalse,argv[i]);
1160             if (colorspace < 0)
1161               ThrowAnimateException(OptionError,"UnrecognizedColorspace",
1162                 argv[i]);
1163             break;
1164           }
1165         if (LocaleCompare("quiet",option+1) == 0)
1166           break;
1167         ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1168       }
1169       case 'r':
1170       {
1171         if (LocaleCompare("regard-warnings",option+1) == 0)
1172           break;
1173         if (LocaleCompare("remote",option+1) == 0)
1174           {
1175             i++;
1176             if (i == (ssize_t) argc)
1177               ThrowAnimateException(OptionError,"MissingArgument",option);
1178             if (XRemoteCommand(display,resource_info.window_id,argv[i]) != 0)
1179               return(MagickFalse);
1180             i--;
1181             break;
1182           }
1183         if (LocaleCompare("repage",option+1) == 0)
1184           {
1185             if (*option == '+')
1186               break;
1187             i++;
1188             if (i == (ssize_t) argc)
1189               ThrowAnimateException(OptionError,"MissingArgument",option);
1190             if (IsGeometry(argv[i]) == MagickFalse)
1191               ThrowAnimateInvalidArgumentException(option,argv[i]);
1192             break;
1193           }
1194         if (LocaleCompare("resample",option+1) == 0)
1195           {
1196             if (*option == '+')
1197               break;
1198             i++;
1199             if (i == (ssize_t) (argc-1))
1200               ThrowAnimateException(OptionError,"MissingArgument",option);
1201             if (IsGeometry(argv[i]) == MagickFalse)
1202               ThrowAnimateInvalidArgumentException(option,argv[i]);
1203             break;
1204           }
1205         if (LocaleCompare("resize",option+1) == 0)
1206           {
1207             if (*option == '+')
1208               break;
1209             i++;
1210             if (i == (ssize_t) argc)
1211               ThrowAnimateException(OptionError,"MissingArgument",option);
1212             if (IsGeometry(argv[i]) == MagickFalse)
1213               ThrowAnimateInvalidArgumentException(option,argv[i]);
1214             break;
1215           }
1216         if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
1217           {
1218             respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
1219             break;
1220           }
1221         if (LocaleCompare("rotate",option+1) == 0)
1222           {
1223             i++;
1224             if (i == (ssize_t) argc)
1225               ThrowAnimateException(OptionError,"MissingArgument",option);
1226             if (IsGeometry(argv[i]) == MagickFalse)
1227               ThrowAnimateInvalidArgumentException(option,argv[i]);
1228             break;
1229           }
1230         ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1231       }
1232       case 's':
1233       {
1234         if (LocaleCompare("sampling-factor",option+1) == 0)
1235           {
1236             if (*option == '+')
1237               break;
1238             i++;
1239             if (i == (ssize_t) argc)
1240               ThrowAnimateException(OptionError,"MissingArgument",option);
1241             if (IsGeometry(argv[i]) == MagickFalse)
1242               ThrowAnimateInvalidArgumentException(option,argv[i]);
1243             break;
1244           }
1245         if (LocaleCompare("seed",option+1) == 0)
1246           {
1247             if (*option == '+')
1248               break;
1249             i++;
1250             if (i == (ssize_t) (argc-1))
1251               ThrowAnimateException(OptionError,"MissingArgument",option);
1252             if (IsGeometry(argv[i]) == MagickFalse)
1253               ThrowAnimateInvalidArgumentException(option,argv[i]);
1254             break;
1255           }
1256         if (LocaleCompare("scenes",option+1) == 0)  /* deprecated */
1257           {
1258             if (*option == '+')
1259               break;
1260             i++;
1261             if (i == (ssize_t) argc)
1262               ThrowAnimateException(OptionError,"MissingArgument",option);
1263             if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
1264               ThrowAnimateInvalidArgumentException(option,argv[i]);
1265             break;
1266           }
1267         if (LocaleCompare("set",option+1) == 0)
1268           {
1269             i++;
1270             if (i == (ssize_t) argc)
1271               ThrowAnimateException(OptionError,"MissingArgument",option);
1272             if (*option == '+')
1273               break;
1274             i++;
1275             if (i == (ssize_t) argc)
1276               ThrowAnimateException(OptionError,"MissingArgument",option);
1277             break;
1278           }
1279         if (LocaleCompare("shared-memory",option+1) == 0)
1280           {
1281             resource_info.use_shared_memory=(*option == '-') ? MagickTrue :
1282               MagickFalse;
1283             break;
1284           }
1285         if (LocaleCompare("size",option+1) == 0)
1286           {
1287             if (*option == '+')
1288               break;
1289             i++;
1290             if (i == (ssize_t) argc)
1291               ThrowAnimateException(OptionError,"MissingArgument",option);
1292             if (IsGeometry(argv[i]) == MagickFalse)
1293               ThrowAnimateInvalidArgumentException(option,argv[i]);
1294             break;
1295           }
1296         if (LocaleCompare("strip",option+1) == 0)
1297           break;
1298         if (LocaleCompare("support",option+1) == 0)
1299           {
1300             i++;  /* deprecated */
1301             break;
1302           }
1303         ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1304       }
1305       case 't':
1306       {
1307         if (LocaleCompare("text-font",option+1) == 0)
1308           {
1309             resource_info.text_font=(char *) NULL;
1310             if (*option == '+')
1311               break;
1312             i++;
1313             if (i == (ssize_t) argc)
1314               ThrowAnimateException(OptionError,"MissingArgument",option);
1315             resource_info.text_font=XGetResourceClass(resource_database,
1316               GetClientName(),"font",argv[i]);
1317             break;
1318           }
1319         if (LocaleCompare("thumbnail",option+1) == 0)
1320           {
1321             if (*option == '+')
1322               break;
1323             i++;
1324             if (i == (ssize_t) argc)
1325               ThrowAnimateException(OptionError,"MissingArgument",option);
1326             if (IsGeometry(argv[i]) == MagickFalse)
1327               ThrowAnimateInvalidArgumentException(option,argv[i]);
1328             break;
1329           }
1330         if (LocaleCompare("title",option+1) == 0)
1331           {
1332             resource_info.title=(char *) NULL;
1333             if (*option == '+')
1334               break;
1335             i++;
1336             if (i == (ssize_t) argc)
1337               ThrowAnimateException(OptionError,"MissingArgument",option);
1338             resource_info.title=argv[i];
1339             break;
1340           }
1341         if (LocaleCompare("transparent-color",option+1) == 0)
1342           {
1343             if (*option == '+')
1344               break;
1345             i++;
1346             if (i == (ssize_t) (argc-1))
1347               ThrowAnimateException(OptionError,"MissingArgument",option);
1348             break;
1349           }
1350         if (LocaleCompare("treedepth",option+1) == 0)
1351           {
1352             quantize_info->tree_depth=0;
1353             if (*option == '+')
1354               break;
1355             i++;
1356             if (i == (ssize_t) argc)
1357               ThrowAnimateException(OptionError,"MissingArgument",option);
1358             if (IsGeometry(argv[i]) == MagickFalse)
1359               ThrowAnimateInvalidArgumentException(option,argv[i]);
1360             quantize_info->tree_depth=StringToUnsignedLong(argv[i]);
1361             break;
1362           }
1363         if (LocaleCompare("trim",option+1) == 0)
1364           break;
1365         ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1366       }
1367       case 'v':
1368       {
1369         if (LocaleCompare("verbose",option+1) == 0)
1370           break;
1371         if ((LocaleCompare("version",option+1) == 0) ||
1372             (LocaleCompare("-version",option+1) == 0))
1373           {
1374             (void) FormatLocaleFile(stdout,"Version: %s\n",
1375               GetMagickVersion((size_t *) NULL));
1376             (void) FormatLocaleFile(stdout,"Copyright: %s\n",
1377               GetMagickCopyright());
1378             (void) FormatLocaleFile(stdout,"Features: %s\n\n",
1379               GetMagickFeatures());
1380             break;
1381           }
1382         if (LocaleCompare("virtual-pixel",option+1) == 0)
1383           {
1384             ssize_t
1385               method;
1386
1387             if (*option == '+')
1388               break;
1389             i++;
1390             if (i == (ssize_t) argc)
1391               ThrowAnimateException(OptionError,"MissingArgument",option);
1392             method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
1393               argv[i]);
1394             if (method < 0)
1395               ThrowAnimateException(OptionError,
1396                 "UnrecognizedVirtualPixelMethod",argv[i]);
1397             break;
1398           }
1399         if (LocaleCompare("visual",option+1) == 0)
1400           {
1401             resource_info.visual_type=(char *) NULL;
1402             if (*option == '+')
1403               break;
1404             i++;
1405             if (i == (ssize_t) argc)
1406               ThrowAnimateException(OptionError,"MissingArgument",option);
1407             resource_info.visual_type=argv[i];
1408             break;
1409           }
1410         ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1411       }
1412       case 'w':
1413       {
1414         if (LocaleCompare("window",option+1) == 0)
1415           {
1416             resource_info.window_id=(char *) NULL;
1417             if (*option == '+')
1418               break;
1419             i++;
1420             if (i == (ssize_t) argc)
1421               ThrowAnimateException(OptionError,"MissingArgument",option);
1422             resource_info.window_id=argv[i];
1423             break;
1424           }
1425         ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1426       }
1427       case '?':
1428         break;
1429       default:
1430         ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1431     }
1432     fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
1433       FireOptionFlag) == 0 ?  MagickFalse : MagickTrue;
1434     if (fire != MagickFalse)
1435       FireImageStack(MagickFalse,MagickTrue,MagickTrue);
1436   }
1437   i--;
1438   if (k != 0)
1439     ThrowAnimateException(OptionError,"UnbalancedParenthesis",argv[i]);
1440   if (image == (Image *) NULL)
1441     ThrowAnimateException(OptionError,"MissingAnImageFilename",argv[argc-1])
1442   FinalizeImageSettings(image_info,image,MagickTrue);
1443   if (image == (Image *) NULL)
1444     ThrowAnimateException(OptionError,"MissingAnImageFilename",argv[argc-1])
1445   if (resource_info.window_id != (char *) NULL)
1446     {
1447       XAnimateBackgroundImage(display,&resource_info,image,exception);
1448       status&=MagickTrue;
1449     }
1450   else
1451     {
1452       Image
1453         *animate_image;
1454
1455       /*
1456         Animate image to X server.
1457       */
1458       animate_image=XAnimateImages(display,&resource_info,argv,argc,image,
1459         exception);
1460       status&=animate_image != (Image *) NULL;
1461       while (animate_image != (Image *) NULL)
1462       {
1463         image=animate_image;
1464         animate_image=XAnimateImages(display,&resource_info,argv,argc,image,
1465           exception);
1466         if (animate_image != image)
1467           image=DestroyImageList(image);
1468       }
1469     }
1470   DestroyAnimate();
1471   return(status != 0 ? MagickTrue : MagickFalse);
1472 #else
1473   (void) argc;
1474   (void) argv;
1475   (void) ThrowMagickException(exception,GetMagickModule(),MissingDelegateError,
1476     "DelegateLibrarySupportNotBuiltIn","`%s' (X11)",image_info->filename);
1477   return(AnimateUsage());
1478 #endif
1479 }