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