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