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