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