2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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 %
13 % Methods to Interactively Animate an Image Sequence %
20 % Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
26 % http://www.imagemagick.org/script/license.php %
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. %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36 % Use the animate program to animate an image sequence on any X server.
43 #include "MagickWand/studio.h"
44 #include "MagickWand/MagickWand.h"
45 #include "MagickWand/mogrify-private.h"
46 #include "MagickCore/animate-private.h"
47 #include "MagickCore/string-private.h"
50 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
54 + A n i m a t e I m a g e C o m m a n d %
58 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
60 % AnimateImageCommand() displays a sequence of images on any workstation
61 % display running an X server. Animate first determines the hardware
62 % capabilities of the workstation. If the number of unique colors in an image
63 % is less than or equal to the number the workstation can support, the image
64 % is displayed in an X window. Otherwise the number of colors in the image is
65 % first reduced to match the color resolution of the workstation before it is
68 % This means that a continuous-tone 24 bits/pixel image can display on a 8
69 % bit pseudo-color device or monochrome device. In most instances the reduced
70 % color image closely resembles the original. Alternatively, a monochrome or
71 % pseudo-color image sequence can display on a continuous-tone 24 bits/pixels
74 % The format of the AnimateImageCommand method is:
76 % MagickBooleanType AnimateImageCommand(ImageInfo *image_info,int argc,
77 % char **argv,char **metadata,ExceptionInfo *exception)
79 % A description of each parameter follows:
81 % o image_info: the image info.
83 % o argc: the number of elements in the argument vector.
85 % o argv: A text array containing the command line arguments.
87 % o metadata: any metadata is returned here.
89 % o exception: return any errors or warnings in this structure.
93 static MagickBooleanType AnimateUsage(void)
101 "Press any button to map or unmap the Command widget",
106 "-debug events display copious debugging information",
107 "-help print program options",
108 "-list type print a list of supported option arguments",
109 "-log format format of debugging information",
110 "-version print version information",
115 "-colors value preferred number of colors in the image",
116 "-crop geometry preferred size and location of the cropped image",
117 "-extract geometry extract area from image",
118 "-monochrome transform image to black and white",
119 "-repage geometry size and location of an image canvas (operator)",
120 "-resample geometry change the resolution of an image",
121 "-resize geometry resize the image",
122 "-rotate degrees apply Paeth rotation to the image",
123 "-strip strip image of all profiles and comments",
124 "-thumbnail geometry create a thumbnail of the image",
125 "-trim trim image edges",
130 "-alpha option on, activate, off, deactivate, set, opaque, copy",
131 " transparent, extract, background, or shape",
132 "-authenticate password",
133 " decipher image with this password",
134 "-backdrop display image centered on a backdrop",
135 "-channel type apply option to select image channels",
136 "-colormap type Shared or Private",
137 "-colorspace type alternate image colorspace",
138 "-decipher filename convert cipher pixels to plain pixels",
139 "-define format:option",
140 " define one or more image format options",
141 "-delay value display the next image after pausing",
142 "-density geometry horizontal and vertical density of the image",
143 "-depth value image depth",
144 "-display server display image to this X server",
145 "-dispose method layer disposal method",
146 "-dither method apply error diffusion to image",
147 "-filter type use this filter when resizing an image",
148 "-format \"string\" output formatted image characteristics",
149 "-gamma value level of gamma correction",
150 "-geometry geometry preferred size and location of the Image window",
151 "-gravity type horizontal and vertical backdrop placement",
152 "-identify identify the format and characteristics of the image",
153 "-immutable displayed image cannot be modified",
154 "-interlace type type of image interlacing scheme",
155 "-interpolate method pixel color interpolation method",
156 "-limit type value pixel cache resource limit",
157 "-loop iterations loop images then exit",
158 "-matte store matte channel if the image has one",
159 "-map type display image using this Standard Colormap",
160 "-monitor monitor progress",
161 "-pause seconds to pause before reanimating",
162 "-page geometry size and location of an image canvas (setting)",
163 "-quantize colorspace reduce colors in this colorspace",
164 "-quiet suppress all warning messages",
165 "-regard-warnings pay attention to warning messages",
166 "-remote command execute a command in an remote display process",
167 "-respect-parentheses settings remain in effect until parenthesis boundary",
168 "-sampling-factor geometry",
169 " horizontal and vertical sampling factor",
170 "-scenes range image scene range",
171 "-seed value seed a new sequence of pseudo-random numbers",
172 "-set attribute value set an image attribute",
173 "-size geometry width and height of image",
174 "-support factor resize support: > 1.0 is blurry, < 1.0 is sharp",
175 "-transparent-color color",
176 " transparent color",
177 "-treedepth value color tree depth",
178 "-verbose print detailed information about the image",
179 "-visual type display image using this visual type",
180 "-virtual-pixel method",
181 " virtual pixel access method",
182 "-window id display image to background of this window",
185 *sequence_operators[]=
187 "-coalesce merge a sequence of images",
188 "-flatten flatten a sequence of images",
192 ListMagickVersion(stdout);
193 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
195 (void) printf("\nImage Settings:\n");
196 for (p=settings; *p != (char *) NULL; p++)
197 (void) printf(" %s\n",*p);
198 (void) printf("\nImage Operators:\n");
199 for (p=operators; *p != (char *) NULL; p++)
200 (void) printf(" %s\n",*p);
201 (void) printf("\nImage Sequence Operators:\n");
202 for (p=sequence_operators; *p != (char *) NULL; p++)
203 (void) printf(" %s\n",*p);
204 (void) printf("\nMiscellaneous Options:\n");
205 for (p=miscellaneous; *p != (char *) NULL; p++)
206 (void) printf(" %s\n",*p);
208 "\nIn addition to those listed above, you can specify these standard X\n");
210 "resources as command line options: -background, -bordercolor,\n");
212 "-borderwidth, -font, -foreground, -iconGeometry, -iconic, -name,\n");
213 (void) printf("-mattecolor, -shared-memory, or -title.\n");
215 "\nBy default, the image format of 'file' is determined by its magic\n");
217 "number. To specify a particular image format, precede the filename\n");
219 "with an image format name and a colon (i.e. ps:image) or specify the\n");
221 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
222 (void) printf("'-' for standard input or output.\n");
223 (void) printf("\nButtons: \n");
224 for (p=buttons; *p != (char *) NULL; p++)
225 (void) printf(" %s\n",*p);
229 WandExport MagickBooleanType AnimateImageCommand(ImageInfo *image_info,
230 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
232 #if defined(MAGICKCORE_X11_DELEGATE)
233 #define DestroyAnimate() \
235 XDestroyResourceInfo(&resource_info); \
236 if (display != (Display *) NULL) \
238 XCloseDisplay(display); \
239 display=(Display *) NULL; \
241 XDestroyResourceInfo(&resource_info); \
242 DestroyImageStack(); \
243 for (i=0; i < (ssize_t) argc; i++) \
244 argv[i]=DestroyString(argv[i]); \
245 argv=(char **) RelinquishMagickMemory(argv); \
247 #define ThrowAnimateException(asperity,tag,option) \
249 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
252 return(MagickFalse); \
254 #define ThrowAnimateInvalidArgumentException(option,argument) \
256 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
257 "InvalidArgument","'%s': %s",option,argument); \
259 return(MagickFalse); \
276 image_stack[MaxImageStackDepth+1];
305 assert(image_info != (ImageInfo *) NULL);
306 assert(image_info->signature == MagickSignature);
307 if (image_info->debug != MagickFalse)
308 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
309 assert(exception != (ExceptionInfo *) NULL);
313 if ((LocaleCompare("version",option+1) == 0) ||
314 (LocaleCompare("-version",option+1) == 0))
316 ListMagickVersion(stdout);
322 display=(Display *) NULL;
326 option=(char *) NULL;
328 respect_parenthesis=MagickFalse;
329 resource_database=(XrmDatabase) NULL;
330 (void) ResetMagickMemory(&resource_info,0,sizeof(XResourceInfo));
331 server_name=(char *) NULL;
334 Check for server name specified on the command line.
336 ReadCommandlLine(argc,&argv);
337 status=ExpandFilenames(&argc,&argv);
338 if (status == MagickFalse)
339 ThrowAnimateException(ResourceLimitError,"MemoryAllocationFailed",
340 image_info->filename);
341 for (i=1; i < (ssize_t) argc; i++)
344 Check command line for server name.
347 if (LocaleCompare("display",option+1) == 0)
350 User specified server name.
353 if (i == (ssize_t) argc)
354 ThrowAnimateException(OptionError,"MissingArgument",option);
357 if ((LocaleCompare("help",option+1) == 0) ||
358 (LocaleCompare("-help",option+1) == 0))
359 return(AnimateUsage());
362 Get user defaults from X resource database.
364 display=XOpenDisplay(server_name);
365 if (display == (Display *) NULL)
366 ThrowAnimateException(XServerError,"UnableToOpenXServer",
367 XDisplayName(server_name));
368 (void) XSetErrorHandler(XError);
369 resource_database=XGetResourceDatabase(display,GetClientName());
370 XGetResourceInfo(image_info,resource_database,GetClientName(),
372 quantize_info=resource_info.quantize_info;
373 image_info->density=XGetResourceInstance(resource_database,GetClientName(),
374 "density",(char *) NULL);
375 if (image_info->density == (char *) NULL)
376 image_info->density=XGetScreenDensity(display);
377 resource_value=XGetResourceInstance(resource_database,GetClientName(),
379 image_info->interlace=(InterlaceType)
380 ParseCommandOption(MagickInterlaceOptions,MagickFalse,resource_value);
381 resource_value=XGetResourceInstance(resource_database,GetClientName(),
383 image_info->verbose=IsStringTrue(resource_value);
384 resource_value=XGetResourceInstance(resource_database,GetClientName(),
386 quantize_info->dither_method=IsStringTrue(resource_value) != MagickFalse ?
387 RiemersmaDitherMethod : NoDitherMethod;
391 for (i=1; i <= (ssize_t) argc; i++)
393 if (i < (ssize_t) argc)
396 if (image != (Image *) NULL)
399 if (isatty(STDIN_FILENO) != MagickFalse)
415 if (LocaleCompare(option,"(") == 0)
417 FireImageStack(MagickFalse,MagickTrue,pend);
418 if (k == MaxImageStackDepth)
419 ThrowAnimateException(OptionError,"ParenthesisNestedTooDeeply",
424 if (LocaleCompare(option,")") == 0)
426 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
428 ThrowAnimateException(OptionError,"UnableToParseExpression",option);
432 if (IsCommandOption(option) == MagickFalse)
443 FireImageStack(MagickFalse,MagickFalse,pend);
445 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
450 if (image_info->ping != MagickFalse)
451 images=PingImages(image_info,filename,exception);
453 images=ReadImages(image_info,filename,exception);
454 status&=(images != (Image *) NULL) &&
455 (exception->severity < ErrorException);
456 if (images == (Image *) NULL)
458 AppendImageStack(images);
461 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
466 if (LocaleCompare("alpha",option+1) == 0)
474 if (i == (ssize_t) argc)
475 ThrowAnimateException(OptionError,"MissingArgument",option);
476 type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,argv[i]);
478 ThrowAnimateException(OptionError,"UnrecognizedAlphaChannelOption",
482 if (LocaleCompare("authenticate",option+1) == 0)
487 if (i == (ssize_t) argc)
488 ThrowAnimateException(OptionError,"MissingArgument",option);
491 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
495 if (LocaleCompare("backdrop",option+1) == 0)
497 resource_info.backdrop=(*option == '-') ? MagickTrue : MagickFalse;
500 if (LocaleCompare("background",option+1) == 0)
505 if (i == (ssize_t) argc)
506 ThrowAnimateException(OptionError,"MissingArgument",option);
507 resource_info.background_color=argv[i];
510 if (LocaleCompare("bordercolor",option+1) == 0)
515 if (i == (ssize_t) argc)
516 ThrowAnimateException(OptionError,"MissingArgument",option);
517 resource_info.border_color=argv[i];
520 if (LocaleCompare("borderwidth",option+1) == 0)
522 resource_info.border_width=0;
526 if ((i == (ssize_t) argc) || (IsGeometry(argv[i]) == MagickFalse))
527 ThrowAnimateException(OptionError,"MissingArgument",option);
528 resource_info.border_width=(unsigned int)
529 StringToUnsignedLong(argv[i]);
532 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
536 if (LocaleCompare("cache",option+1) == 0)
541 if (i == (ssize_t) argc)
542 ThrowAnimateException(OptionError,"MissingArgument",option);
543 if (IsGeometry(argv[i]) == MagickFalse)
544 ThrowAnimateInvalidArgumentException(option,argv[i]);
547 if (LocaleCompare("channel",option+1) == 0)
555 if (i == (ssize_t) argc)
556 ThrowAnimateException(OptionError,"MissingArgument",option);
557 channel=ParseChannelOption(argv[i]);
559 ThrowAnimateException(OptionError,"UnrecognizedChannelType",
563 if (LocaleCompare("clone",option+1) == 0)
570 clone_images=image_stack[k-1].image;
571 if (clone_images == (Image *) NULL)
572 ThrowAnimateException(ImageError,"UnableToCloneImage",option);
573 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
575 clone_images=CloneImages(clone_images,"-1",exception);
579 if (i == (ssize_t) argc)
580 ThrowAnimateException(OptionError,"MissingArgument",option);
581 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
582 ThrowAnimateInvalidArgumentException(option,argv[i]);
583 clone_images=CloneImages(clone_images,argv[i],exception);
585 if (clone_images == (Image *) NULL)
586 ThrowAnimateException(OptionError,"NoSuchImage",option);
587 AppendImageStack(clone_images);
590 if (LocaleCompare("coalesce",option+1) == 0)
592 if (LocaleCompare("colormap",option+1) == 0)
594 resource_info.colormap=PrivateColormap;
598 if (i == (ssize_t) argc)
599 ThrowAnimateException(OptionError,"MissingArgument",option);
600 resource_info.colormap=UndefinedColormap;
601 if (LocaleCompare("private",argv[i]) == 0)
602 resource_info.colormap=PrivateColormap;
603 if (LocaleCompare("shared",argv[i]) == 0)
604 resource_info.colormap=SharedColormap;
605 if (resource_info.colormap == UndefinedColormap)
606 ThrowAnimateException(OptionError,"UnrecognizedColormapType",
610 if (LocaleCompare("colors",option+1) == 0)
612 quantize_info->number_colors=0;
616 if (i == (ssize_t) argc)
617 ThrowAnimateException(OptionError,"MissingArgument",option);
618 if (IsGeometry(argv[i]) == MagickFalse)
619 ThrowAnimateInvalidArgumentException(option,argv[i]);
620 quantize_info->number_colors=StringToUnsignedLong(argv[i]);
623 if (LocaleCompare("colorspace",option+1) == 0)
631 if (i == (ssize_t) argc)
632 ThrowAnimateException(OptionError,"MissingArgument",option);
633 colorspace=ParseCommandOption(MagickColorspaceOptions,
634 MagickFalse,argv[i]);
636 ThrowAnimateException(OptionError,"UnrecognizedColorspace",
640 if (LocaleCompare("concurrent",option+1) == 0)
642 if (LocaleCompare("crop",option+1) == 0)
647 if (i == (ssize_t) argc)
648 ThrowAnimateException(OptionError,"MissingArgument",option);
649 if (IsGeometry(argv[i]) == MagickFalse)
650 ThrowAnimateInvalidArgumentException(option,argv[i]);
653 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
657 if (LocaleCompare("debug",option+1) == 0)
665 if (i == (ssize_t) argc)
666 ThrowAnimateException(OptionError,"MissingArgument",option);
667 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
669 ThrowAnimateException(OptionError,"UnrecognizedEventType",
671 (void) SetLogEventMask(argv[i]);
674 if (LocaleCompare("decipher",option+1) == 0)
679 if (i == (ssize_t) argc)
680 ThrowAnimateException(OptionError,"MissingArgument",option);
683 if (LocaleCompare("define",option+1) == 0)
686 if (i == (ssize_t) argc)
687 ThrowAnimateException(OptionError,"MissingArgument",option);
693 define=GetImageOption(image_info,argv[i]);
694 if (define == (const char *) NULL)
695 ThrowAnimateException(OptionError,"NoSuchOption",argv[i]);
700 if (LocaleCompare("delay",option+1) == 0)
705 if (i == (ssize_t) argc)
706 ThrowAnimateException(OptionError,"MissingArgument",option);
707 if (IsGeometry(argv[i]) == MagickFalse)
708 ThrowAnimateInvalidArgumentException(option,argv[i]);
711 if (LocaleCompare("density",option+1) == 0)
716 if (i == (ssize_t) argc)
717 ThrowAnimateException(OptionError,"MissingArgument",option);
718 if (IsGeometry(argv[i]) == MagickFalse)
719 ThrowAnimateInvalidArgumentException(option,argv[i]);
722 if (LocaleCompare("depth",option+1) == 0)
727 if (i == (ssize_t) argc)
728 ThrowAnimateException(OptionError,"MissingArgument",option);
729 if (IsGeometry(argv[i]) == MagickFalse)
730 ThrowAnimateInvalidArgumentException(option,argv[i]);
733 if (LocaleCompare("display",option+1) == 0)
738 if (i == (ssize_t) argc)
739 ThrowAnimateException(OptionError,"MissingArgument",option);
742 if (LocaleCompare("dispose",option+1) == 0)
750 if (i == (ssize_t) argc)
751 ThrowAnimateException(OptionError,"MissingArgument",option);
752 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
754 ThrowAnimateException(OptionError,"UnrecognizedDisposeMethod",
758 if (LocaleCompare("dither",option+1) == 0)
763 quantize_info->dither_method=NoDitherMethod;
767 if (i == (ssize_t) argc)
768 ThrowAnimateException(OptionError,"MissingArgument",option);
769 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
771 ThrowAnimateException(OptionError,"UnrecognizedDitherMethod",
773 quantize_info->dither_method=(DitherMethod) method;
776 if (LocaleCompare("duration",option+1) == 0)
781 if (i == (ssize_t) argc)
782 ThrowAnimateException(OptionError,"MissingArgument",option);
783 if (IsGeometry(argv[i]) == MagickFalse)
784 ThrowAnimateInvalidArgumentException(option,argv[i]);
787 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
791 if (LocaleCompare("extract",option+1) == 0)
796 if (i == (ssize_t) argc)
797 ThrowAnimateException(OptionError,"MissingArgument",option);
798 if (IsGeometry(argv[i]) == MagickFalse)
799 ThrowAnimateInvalidArgumentException(option,argv[i]);
802 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
806 if (LocaleCompare("filter",option+1) == 0)
814 if (i == (ssize_t) argc)
815 ThrowAnimateException(OptionError,"MissingArgument",option);
816 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
818 ThrowAnimateException(OptionError,"UnrecognizedImageFilter",
822 if (LocaleCompare("flatten",option+1) == 0)
824 if (LocaleCompare("font",option+1) == 0)
829 if (i == (ssize_t) argc)
830 ThrowAnimateException(OptionError,"MissingArgument",option);
831 resource_info.font=XGetResourceClass(resource_database,
832 GetClientName(),"font",argv[i]);
835 if (LocaleCompare("foreground",option+1) == 0)
840 if (i == (ssize_t) argc)
841 ThrowAnimateException(OptionError,"MissingArgument",option);
842 resource_info.foreground_color=argv[i];
845 if (LocaleCompare("format",option+1) == 0)
850 if (i == (ssize_t) argc)
851 ThrowAnimateException(OptionError,"MissingArgument",option);
854 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
858 if (LocaleCompare("gamma",option+1) == 0)
861 if (i == (ssize_t) argc)
862 ThrowAnimateException(OptionError,"MissingArgument",option);
863 if (IsGeometry(argv[i]) == MagickFalse)
864 ThrowAnimateInvalidArgumentException(option,argv[i]);
867 if (LocaleCompare("geometry",option+1) == 0)
869 resource_info.image_geometry=(char *) NULL;
873 if (i == (ssize_t) argc)
874 ThrowAnimateException(OptionError,"MissingArgument",option);
875 if (IsGeometry(argv[i]) == MagickFalse)
876 ThrowAnimateInvalidArgumentException(option,argv[i]);
877 resource_info.image_geometry=ConstantString(argv[i]);
880 if (LocaleCompare("gravity",option+1) == 0)
888 if (i == (ssize_t) argc)
889 ThrowAnimateException(OptionError,"MissingArgument",option);
890 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
893 ThrowAnimateException(OptionError,"UnrecognizedGravityType",
897 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
901 if ((LocaleCompare("help",option+1) == 0) ||
902 (LocaleCompare("-help",option+1) == 0))
904 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
908 if (LocaleCompare("iconGeometry",option+1) == 0)
910 resource_info.icon_geometry=(char *) NULL;
914 if (i == (ssize_t) argc)
915 ThrowAnimateException(OptionError,"MissingArgument",option);
916 if (IsGeometry(argv[i]) == MagickFalse)
917 ThrowAnimateInvalidArgumentException(option,argv[i]);
918 resource_info.icon_geometry=argv[i];
921 if (LocaleCompare("iconic",option+1) == 0)
923 resource_info.iconic=(*option == '-') ? MagickTrue : MagickFalse;
926 if (LocaleCompare("identify",option+1) == 0)
928 if (LocaleCompare("immutable",option+1) == 0)
930 resource_info.immutable=(*option == '-') ? MagickTrue : MagickFalse;
933 if (LocaleCompare("interlace",option+1) == 0)
941 if (i == (ssize_t) argc)
942 ThrowAnimateException(OptionError,"MissingArgument",option);
943 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
946 ThrowAnimateException(OptionError,"UnrecognizedInterlaceType",
950 if (LocaleCompare("interpolate",option+1) == 0)
958 if (i == (ssize_t) argc)
959 ThrowAnimateException(OptionError,"MissingArgument",option);
960 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
963 ThrowAnimateException(OptionError,"UnrecognizedInterpolateMethod",
967 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
971 if (LocaleCompare("label",option+1) == 0)
976 if (i == (ssize_t) argc)
977 ThrowAnimateException(OptionError,"MissingArgument",option);
980 if (LocaleCompare("limit",option+1) == 0)
994 if (i == (ssize_t) argc)
995 ThrowAnimateException(OptionError,"MissingArgument",option);
996 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
999 ThrowAnimateException(OptionError,"UnrecognizedResourceType",
1002 if (i == (ssize_t) argc)
1003 ThrowAnimateException(OptionError,"MissingArgument",option);
1004 value=StringToDouble(argv[i],&p);
1006 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
1007 ThrowAnimateInvalidArgumentException(option,argv[i]);
1010 if (LocaleCompare("list",option+1) == 0)
1018 if (i == (ssize_t) argc)
1019 ThrowAnimateException(OptionError,"MissingArgument",option);
1020 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
1022 ThrowAnimateException(OptionError,"UnrecognizedListType",argv[i]);
1023 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
1026 return(status != 0 ? MagickFalse : MagickTrue);
1028 if (LocaleCompare("log",option+1) == 0)
1033 if ((i == (ssize_t) argc) ||
1034 (strchr(argv[i],'%') == (char *) NULL))
1035 ThrowAnimateException(OptionError,"MissingArgument",option);
1038 if (LocaleCompare("loop",option+1) == 0)
1043 if (i == (ssize_t) argc)
1044 ThrowAnimateException(OptionError,"MissingArgument",option);
1045 if (IsGeometry(argv[i]) == MagickFalse)
1046 ThrowAnimateInvalidArgumentException(option,argv[i]);
1049 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1053 if (LocaleCompare("map",option+1) == 0)
1055 resource_info.map_type=(char *) NULL;
1058 (void) CopyMagickString(argv[i]+1,"san",MaxTextExtent);
1060 if (i == (ssize_t) argc)
1061 ThrowAnimateException(OptionError,"MissingArgument",option);
1062 resource_info.map_type=argv[i];
1065 if (LocaleCompare("matte",option+1) == 0)
1067 if (LocaleCompare("mattecolor",option+1) == 0)
1072 if (i == (ssize_t) argc)
1073 ThrowAnimateException(OptionError,"MissingArgument",option);
1074 resource_info.matte_color=argv[i];
1077 if (LocaleCompare("monitor",option+1) == 0)
1079 if (LocaleCompare("monochrome",option+1) == 0)
1083 quantize_info->number_colors=2;
1084 quantize_info->colorspace=GRAYColorspace;
1087 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1091 if (LocaleCompare("name",option+1) == 0)
1093 resource_info.name=(char *) NULL;
1097 if (i == (ssize_t) argc)
1098 ThrowAnimateException(OptionError,"MissingArgument",option);
1099 resource_info.name=ConstantString(argv[i]);
1102 if (LocaleCompare("noop",option+1) == 0)
1104 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1108 if (LocaleCompare("pause",option+1) == 0)
1110 resource_info.pause=0;
1114 if (i == (ssize_t) argc)
1115 ThrowAnimateException(OptionError,"MissingArgument",option);
1116 if (IsGeometry(argv[i]) == MagickFalse)
1117 ThrowAnimateInvalidArgumentException(option,argv[i]);
1118 resource_info.pause=(unsigned int) StringToUnsignedLong(argv[i]);
1121 if (LocaleCompare("page",option+1) == 0)
1126 if (i == (ssize_t) argc)
1127 ThrowAnimateException(OptionError,"MissingArgument",option);
1130 if (LocaleCompare("profile",option+1) == 0)
1133 if (i == (ssize_t) argc)
1134 ThrowAnimateException(OptionError,"MissingArgument",option);
1137 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1141 if (LocaleCompare("quantize",option+1) == 0)
1149 if (i == (ssize_t) argc)
1150 ThrowAnimateException(OptionError,"MissingArgument",option);
1151 colorspace=ParseCommandOption(MagickColorspaceOptions,
1152 MagickFalse,argv[i]);
1154 ThrowAnimateException(OptionError,"UnrecognizedColorspace",
1158 if (LocaleCompare("quiet",option+1) == 0)
1160 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1164 if (LocaleCompare("regard-warnings",option+1) == 0)
1166 if (LocaleCompare("remote",option+1) == 0)
1169 if (i == (ssize_t) argc)
1170 ThrowAnimateException(OptionError,"MissingArgument",option);
1171 if (XRemoteCommand(display,resource_info.window_id,argv[i]) != 0)
1172 return(MagickFalse);
1176 if (LocaleCompare("repage",option+1) == 0)
1181 if (i == (ssize_t) argc)
1182 ThrowAnimateException(OptionError,"MissingArgument",option);
1183 if (IsGeometry(argv[i]) == MagickFalse)
1184 ThrowAnimateInvalidArgumentException(option,argv[i]);
1187 if (LocaleCompare("resample",option+1) == 0)
1192 if (i == (ssize_t) argc)
1193 ThrowAnimateException(OptionError,"MissingArgument",option);
1194 if (IsGeometry(argv[i]) == MagickFalse)
1195 ThrowAnimateInvalidArgumentException(option,argv[i]);
1198 if (LocaleCompare("resize",option+1) == 0)
1203 if (i == (ssize_t) argc)
1204 ThrowAnimateException(OptionError,"MissingArgument",option);
1205 if (IsGeometry(argv[i]) == MagickFalse)
1206 ThrowAnimateInvalidArgumentException(option,argv[i]);
1209 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
1211 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
1214 if (LocaleCompare("rotate",option+1) == 0)
1217 if (i == (ssize_t) argc)
1218 ThrowAnimateException(OptionError,"MissingArgument",option);
1219 if (IsGeometry(argv[i]) == MagickFalse)
1220 ThrowAnimateInvalidArgumentException(option,argv[i]);
1223 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1227 if (LocaleCompare("sampling-factor",option+1) == 0)
1232 if (i == (ssize_t) argc)
1233 ThrowAnimateException(OptionError,"MissingArgument",option);
1234 if (IsGeometry(argv[i]) == MagickFalse)
1235 ThrowAnimateInvalidArgumentException(option,argv[i]);
1238 if (LocaleCompare("seed",option+1) == 0)
1243 if (i == (ssize_t) argc)
1244 ThrowAnimateException(OptionError,"MissingArgument",option);
1245 if (IsGeometry(argv[i]) == MagickFalse)
1246 ThrowAnimateInvalidArgumentException(option,argv[i]);
1249 if (LocaleCompare("scenes",option+1) == 0) /* deprecated */
1254 if (i == (ssize_t) argc)
1255 ThrowAnimateException(OptionError,"MissingArgument",option);
1256 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
1257 ThrowAnimateInvalidArgumentException(option,argv[i]);
1260 if (LocaleCompare("set",option+1) == 0)
1263 if (i == (ssize_t) argc)
1264 ThrowAnimateException(OptionError,"MissingArgument",option);
1268 if (i == (ssize_t) argc)
1269 ThrowAnimateException(OptionError,"MissingArgument",option);
1272 if (LocaleCompare("shared-memory",option+1) == 0)
1274 resource_info.use_shared_memory=(*option == '-') ? MagickTrue :
1278 if (LocaleCompare("size",option+1) == 0)
1283 if (i == (ssize_t) argc)
1284 ThrowAnimateException(OptionError,"MissingArgument",option);
1285 if (IsGeometry(argv[i]) == MagickFalse)
1286 ThrowAnimateInvalidArgumentException(option,argv[i]);
1289 if (LocaleCompare("strip",option+1) == 0)
1291 if (LocaleCompare("support",option+1) == 0)
1293 i++; /* deprecated */
1296 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1300 if (LocaleCompare("text-font",option+1) == 0)
1302 resource_info.text_font=(char *) NULL;
1306 if (i == (ssize_t) argc)
1307 ThrowAnimateException(OptionError,"MissingArgument",option);
1308 resource_info.text_font=XGetResourceClass(resource_database,
1309 GetClientName(),"font",argv[i]);
1312 if (LocaleCompare("thumbnail",option+1) == 0)
1317 if (i == (ssize_t) argc)
1318 ThrowAnimateException(OptionError,"MissingArgument",option);
1319 if (IsGeometry(argv[i]) == MagickFalse)
1320 ThrowAnimateInvalidArgumentException(option,argv[i]);
1323 if (LocaleCompare("title",option+1) == 0)
1325 resource_info.title=(char *) NULL;
1329 if (i == (ssize_t) argc)
1330 ThrowAnimateException(OptionError,"MissingArgument",option);
1331 resource_info.title=argv[i];
1334 if (LocaleCompare("transparent-color",option+1) == 0)
1339 if (i == (ssize_t) argc)
1340 ThrowAnimateException(OptionError,"MissingArgument",option);
1343 if (LocaleCompare("treedepth",option+1) == 0)
1345 quantize_info->tree_depth=0;
1349 if (i == (ssize_t) argc)
1350 ThrowAnimateException(OptionError,"MissingArgument",option);
1351 if (IsGeometry(argv[i]) == MagickFalse)
1352 ThrowAnimateInvalidArgumentException(option,argv[i]);
1353 quantize_info->tree_depth=StringToUnsignedLong(argv[i]);
1356 if (LocaleCompare("trim",option+1) == 0)
1358 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1362 if (LocaleCompare("verbose",option+1) == 0)
1364 if ((LocaleCompare("version",option+1) == 0) ||
1365 (LocaleCompare("-version",option+1) == 0))
1367 ListMagickVersion(stdout);
1370 if (LocaleCompare("virtual-pixel",option+1) == 0)
1378 if (i == (ssize_t) argc)
1379 ThrowAnimateException(OptionError,"MissingArgument",option);
1380 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
1383 ThrowAnimateException(OptionError,
1384 "UnrecognizedVirtualPixelMethod",argv[i]);
1387 if (LocaleCompare("visual",option+1) == 0)
1389 resource_info.visual_type=(char *) NULL;
1393 if (i == (ssize_t) argc)
1394 ThrowAnimateException(OptionError,"MissingArgument",option);
1395 resource_info.visual_type=argv[i];
1398 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1402 if (LocaleCompare("window",option+1) == 0)
1404 resource_info.window_id=(char *) NULL;
1408 if (i == (ssize_t) argc)
1409 ThrowAnimateException(OptionError,"MissingArgument",option);
1410 resource_info.window_id=argv[i];
1413 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1418 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1420 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
1421 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
1422 if (fire != MagickFalse)
1423 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
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)
1435 XAnimateBackgroundImage(display,&resource_info,image,exception);
1444 Animate image to X server.
1446 animate_image=XAnimateImages(display,&resource_info,argv,argc,image,
1448 status&=animate_image != (Image *) NULL;
1449 while (animate_image != (Image *) NULL)
1451 image=animate_image;
1452 animate_image=XAnimateImages(display,&resource_info,argv,argc,image,
1454 if (animate_image != image)
1455 image=DestroyImageList(image);
1459 return(status != 0 ? MagickTrue : MagickFalse);
1463 (void) ThrowMagickException(exception,GetMagickModule(),MissingDelegateError,
1464 "DelegateLibrarySupportNotBuiltIn","'%s' (X11)",image_info->filename);
1465 return(AnimateUsage());