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-2011 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"
48 #include "MagickCore/xwindow-private.h"
51 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
55 + A n i m a t e I m a g e C o m m a n d %
59 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
61 % AnimateImageCommand() displays a sequence of images on any workstation
62 % display running an X server. Animate first determines the hardware
63 % capabilities of the workstation. If the number of unique colors in an image
64 % is less than or equal to the number the workstation can support, the image
65 % is displayed in an X window. Otherwise the number of colors in the image is
66 % first reduced to match the color resolution of the workstation before it is
69 % This means that a continuous-tone 24 bits/pixel image can display on a 8
70 % bit pseudo-color device or monochrome device. In most instances the reduced
71 % color image closely resembles the original. Alternatively, a monochrome or
72 % pseudo-color image sequence can display on a continuous-tone 24 bits/pixels
75 % The format of the AnimateImageCommand method is:
77 % MagickBooleanType AnimateImageCommand(ImageInfo *image_info,int argc,
78 % char **argv,char **metadata,ExceptionInfo *exception)
80 % A description of each parameter follows:
82 % o image_info: the image info.
84 % o argc: the number of elements in the argument vector.
86 % o argv: A text array containing the command line arguments.
88 % o metadata: any metadata is returned here.
90 % o exception: return any errors or warnings in this structure.
94 static MagickBooleanType AnimateUsage(void)
102 "Press any button to map or unmap the Command widget",
107 "-debug events display copious debugging information",
108 "-help print program options",
109 "-list type print a list of supported option arguments",
110 "-log format format of debugging information",
111 "-version print version information",
116 "-colors value preferred number of colors in the image",
117 "-crop geometry preferred size and location of the cropped image",
118 "-extract geometry extract area from image",
119 "-monochrome transform image to black and white",
120 "-repage geometry size and location of an image canvas (operator)",
121 "-resample geometry change the resolution of an image",
122 "-resize geometry resize the image",
123 "-rotate degrees apply Paeth rotation to the image",
124 "-strip strip image of all profiles and comments",
125 "-thumbnail geometry create a thumbnail of the image",
126 "-trim trim image edges",
131 "-alpha option on, activate, off, deactivate, set, opaque, copy",
132 " transparent, extract, background, or shape",
133 "-authenticate password",
134 " decipher image with this password",
135 "-backdrop display image centered on a backdrop",
136 "-channel type apply option to select image channels",
137 "-colormap type Shared or Private",
138 "-colorspace type alternate image colorspace",
139 "-decipher filename convert cipher pixels to plain pixels",
140 "-define format:option",
141 " define one or more image format options",
142 "-delay value display the next image after pausing",
143 "-density geometry horizontal and vertical density of the image",
144 "-depth value image depth",
145 "-display server display image to this X server",
146 "-dispose method layer disposal method",
147 "-dither method apply error diffusion to image",
148 "-filter type use this filter when resizing an image",
149 "-format \"string\" output formatted image characteristics",
150 "-gamma value level of gamma correction",
151 "-geometry geometry preferred size and location of the Image window",
152 "-gravity type horizontal and vertical backdrop placement",
153 "-identify identify the format and characteristics of the image",
154 "-immutable displayed image cannot be modified",
155 "-interlace type type of image interlacing scheme",
156 "-interpolate method pixel color interpolation method",
157 "-limit type value pixel cache resource limit",
158 "-loop iterations loop images then exit",
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 "-seed value seed a new sequence of pseudo-random numbers",
171 "-set attribute value set an image attribute",
172 "-size geometry width and height of image",
173 "-transparent-color color",
174 " transparent color",
175 "-treedepth value color tree depth",
176 "-verbose print detailed information about the image",
177 "-visual type display image using this visual type",
178 "-virtual-pixel method",
179 " virtual pixel access method",
180 "-window id display image to background of this window",
183 *sequence_operators[]=
185 "-coalesce merge a sequence of images",
186 "-flatten flatten a sequence of images",
190 (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
191 (void) printf("Copyright: %s\n",GetMagickCopyright());
192 (void) printf("Features: %s\n\n",GetMagickFeatures());
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 (void) FormatLocaleFile(stdout,"Version: %s\n",
317 GetMagickVersion((size_t *) NULL));
318 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
319 GetMagickCopyright());
320 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
321 GetMagickFeatures());
327 display=(Display *) NULL;
331 option=(char *) NULL;
333 respect_parenthesis=MagickFalse;
334 resource_database=(XrmDatabase) NULL;
335 (void) ResetMagickMemory(&resource_info,0,sizeof(XResourceInfo));
336 server_name=(char *) NULL;
339 Check for server name specified on the command line.
341 ReadCommandlLine(argc,&argv);
342 status=ExpandFilenames(&argc,&argv);
343 if (status == MagickFalse)
344 ThrowAnimateException(ResourceLimitError,"MemoryAllocationFailed",
345 image_info->filename);
346 for (i=1; i < (ssize_t) argc; i++)
349 Check command line for server name.
352 if (LocaleCompare("display",option+1) == 0)
355 User specified server name.
358 if (i == (ssize_t) argc)
359 ThrowAnimateException(OptionError,"MissingArgument",option);
362 if ((LocaleCompare("help",option+1) == 0) ||
363 (LocaleCompare("-help",option+1) == 0))
364 return(AnimateUsage());
367 Get user defaults from X resource database.
369 display=XOpenDisplay(server_name);
370 if (display == (Display *) NULL)
371 ThrowAnimateException(XServerError,"UnableToOpenXServer",
372 XDisplayName(server_name));
373 (void) XSetErrorHandler(XError);
374 resource_database=XGetResourceDatabase(display,GetClientName());
375 XGetResourceInfo(image_info,resource_database,GetClientName(),
377 quantize_info=resource_info.quantize_info;
378 image_info->density=XGetResourceInstance(resource_database,GetClientName(),
379 "density",(char *) NULL);
380 if (image_info->density == (char *) NULL)
381 image_info->density=XGetScreenDensity(display);
382 resource_value=XGetResourceInstance(resource_database,GetClientName(),
384 image_info->interlace=(InterlaceType)
385 ParseCommandOption(MagickInterlaceOptions,MagickFalse,resource_value);
386 resource_value=XGetResourceInstance(resource_database,GetClientName(),
388 image_info->verbose=IsMagickTrue(resource_value);
389 resource_value=XGetResourceInstance(resource_database,GetClientName(),
391 quantize_info->dither=IsMagickTrue(resource_value);
395 for (i=1; i <= (ssize_t) argc; i++)
397 if (i < (ssize_t) argc)
400 if (image != (Image *) NULL)
403 if (isatty(STDIN_FILENO) != MagickFalse)
419 if (LocaleCompare(option,"(") == 0)
421 FireImageStack(MagickFalse,MagickTrue,pend);
422 if (k == MaxImageStackDepth)
423 ThrowAnimateException(OptionError,"ParenthesisNestedTooDeeply",
428 if (LocaleCompare(option,")") == 0)
430 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
432 ThrowAnimateException(OptionError,"UnableToParseExpression",option);
436 if (IsCommandOption(option) == MagickFalse)
447 FireImageStack(MagickFalse,MagickFalse,pend);
449 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
454 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
455 if (image_info->ping != MagickFalse)
456 images=PingImages(image_info,exception);
458 images=ReadImages(image_info,exception);
459 status&=(images != (Image *) NULL) &&
460 (exception->severity < ErrorException);
461 if (images == (Image *) NULL)
463 AppendImageStack(images);
466 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
471 if (LocaleCompare("alpha",option+1) == 0)
479 if (i == (ssize_t) argc)
480 ThrowAnimateException(OptionError,"MissingArgument",option);
481 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
483 ThrowAnimateException(OptionError,"UnrecognizedAlphaChannelType",
487 if (LocaleCompare("authenticate",option+1) == 0)
492 if (i == (ssize_t) argc)
493 ThrowAnimateException(OptionError,"MissingArgument",option);
496 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
500 if (LocaleCompare("backdrop",option+1) == 0)
502 resource_info.backdrop=(*option == '-') ? MagickTrue : MagickFalse;
505 if (LocaleCompare("background",option+1) == 0)
510 if (i == (ssize_t) argc)
511 ThrowAnimateException(OptionError,"MissingArgument",option);
512 resource_info.background_color=argv[i];
515 if (LocaleCompare("bordercolor",option+1) == 0)
520 if (i == (ssize_t) argc)
521 ThrowAnimateException(OptionError,"MissingArgument",option);
522 resource_info.border_color=argv[i];
525 if (LocaleCompare("borderwidth",option+1) == 0)
527 resource_info.border_width=0;
531 if ((i == (ssize_t) argc) || (IsGeometry(argv[i]) == MagickFalse))
532 ThrowAnimateException(OptionError,"MissingArgument",option);
533 resource_info.border_width=(unsigned int)
534 StringToUnsignedLong(argv[i]);
537 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
541 if (LocaleCompare("cache",option+1) == 0)
546 if (i == (ssize_t) argc)
547 ThrowAnimateException(OptionError,"MissingArgument",option);
548 if (IsGeometry(argv[i]) == MagickFalse)
549 ThrowAnimateInvalidArgumentException(option,argv[i]);
552 if (LocaleCompare("channel",option+1) == 0)
560 if (i == (ssize_t) (argc-1))
561 ThrowAnimateException(OptionError,"MissingArgument",option);
562 channel=ParseChannelOption(argv[i]);
564 ThrowAnimateException(OptionError,"UnrecognizedChannelType",
568 if (LocaleCompare("clone",option+1) == 0)
575 clone_images=image_stack[k-1].image;
576 if (clone_images == (Image *) NULL)
577 ThrowAnimateException(ImageError,"ImageSequenceRequired",option);
578 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
580 clone_images=CloneImages(clone_images,"-1",exception);
584 if (i == (ssize_t) (argc-1))
585 ThrowAnimateException(OptionError,"MissingArgument",option);
586 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
587 ThrowAnimateInvalidArgumentException(option,argv[i]);
588 clone_images=CloneImages(clone_images,argv[i],exception);
590 if (clone_images == (Image *) NULL)
591 ThrowAnimateException(OptionError,"NoSuchImage",option);
592 AppendImageStack(clone_images);
595 if (LocaleCompare("coalesce",option+1) == 0)
597 if (LocaleCompare("colormap",option+1) == 0)
599 resource_info.colormap=PrivateColormap;
603 if (i == (ssize_t) argc)
604 ThrowAnimateException(OptionError,"MissingArgument",option);
605 resource_info.colormap=UndefinedColormap;
606 if (LocaleCompare("private",argv[i]) == 0)
607 resource_info.colormap=PrivateColormap;
608 if (LocaleCompare("shared",argv[i]) == 0)
609 resource_info.colormap=SharedColormap;
610 if (resource_info.colormap == UndefinedColormap)
611 ThrowAnimateException(OptionError,"UnrecognizedColormapType",
615 if (LocaleCompare("colors",option+1) == 0)
617 quantize_info->number_colors=0;
621 if (i == (ssize_t) argc)
622 ThrowAnimateException(OptionError,"MissingArgument",option);
623 if (IsGeometry(argv[i]) == MagickFalse)
624 ThrowAnimateInvalidArgumentException(option,argv[i]);
625 quantize_info->number_colors=StringToUnsignedLong(argv[i]);
628 if (LocaleCompare("colorspace",option+1) == 0)
636 if (i == (ssize_t) argc)
637 ThrowAnimateException(OptionError,"MissingArgument",option);
638 colorspace=ParseCommandOption(MagickColorspaceOptions,
639 MagickFalse,argv[i]);
641 ThrowAnimateException(OptionError,"UnrecognizedColorspace",
645 if (LocaleCompare("concurrent",option+1) == 0)
647 if (LocaleCompare("crop",option+1) == 0)
652 if (i == (ssize_t) argc)
653 ThrowAnimateException(OptionError,"MissingArgument",option);
654 if (IsGeometry(argv[i]) == MagickFalse)
655 ThrowAnimateInvalidArgumentException(option,argv[i]);
658 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
662 if (LocaleCompare("debug",option+1) == 0)
670 if (i == (ssize_t) argc)
671 ThrowAnimateException(OptionError,"MissingArgument",option);
672 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
674 ThrowAnimateException(OptionError,"UnrecognizedEventType",
676 (void) SetLogEventMask(argv[i]);
679 if (LocaleCompare("decipher",option+1) == 0)
684 if (i == (ssize_t) (argc-1))
685 ThrowAnimateException(OptionError,"MissingArgument",option);
688 if (LocaleCompare("define",option+1) == 0)
691 if (i == (ssize_t) argc)
692 ThrowAnimateException(OptionError,"MissingArgument",option);
698 define=GetImageOption(image_info,argv[i]);
699 if (define == (const char *) NULL)
700 ThrowAnimateException(OptionError,"NoSuchOption",argv[i]);
705 if (LocaleCompare("delay",option+1) == 0)
710 if (i == (ssize_t) argc)
711 ThrowAnimateException(OptionError,"MissingArgument",option);
712 if (IsGeometry(argv[i]) == MagickFalse)
713 ThrowAnimateInvalidArgumentException(option,argv[i]);
716 if (LocaleCompare("density",option+1) == 0)
721 if (i == (ssize_t) argc)
722 ThrowAnimateException(OptionError,"MissingArgument",option);
723 if (IsGeometry(argv[i]) == MagickFalse)
724 ThrowAnimateInvalidArgumentException(option,argv[i]);
727 if (LocaleCompare("depth",option+1) == 0)
732 if (i == (ssize_t) argc)
733 ThrowAnimateException(OptionError,"MissingArgument",option);
734 if (IsGeometry(argv[i]) == MagickFalse)
735 ThrowAnimateInvalidArgumentException(option,argv[i]);
738 if (LocaleCompare("display",option+1) == 0)
743 if (i == (ssize_t) argc)
744 ThrowAnimateException(OptionError,"MissingArgument",option);
747 if (LocaleCompare("dispose",option+1) == 0)
755 if (i == (ssize_t) argc)
756 ThrowAnimateException(OptionError,"MissingArgument",option);
757 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
759 ThrowAnimateException(OptionError,"UnrecognizedDisposeMethod",
763 if (LocaleCompare("dither",option+1) == 0)
768 quantize_info->dither=MagickFalse;
772 if (i == (ssize_t) argc)
773 ThrowAnimateException(OptionError,"MissingArgument",option);
774 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
776 ThrowAnimateException(OptionError,"UnrecognizedDitherMethod",
778 quantize_info->dither=MagickTrue;
779 quantize_info->dither_method=(DitherMethod) method;
782 if (LocaleCompare("duration",option+1) == 0)
787 if (i == (ssize_t) (argc-1))
788 ThrowAnimateException(OptionError,"MissingArgument",option);
789 if (IsGeometry(argv[i]) == MagickFalse)
790 ThrowAnimateInvalidArgumentException(option,argv[i]);
793 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
797 if (LocaleCompare("extract",option+1) == 0)
802 if (i == (ssize_t) argc)
803 ThrowAnimateException(OptionError,"MissingArgument",option);
804 if (IsGeometry(argv[i]) == MagickFalse)
805 ThrowAnimateInvalidArgumentException(option,argv[i]);
808 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
812 if (LocaleCompare("filter",option+1) == 0)
820 if (i == (ssize_t) (argc-1))
821 ThrowAnimateException(OptionError,"MissingArgument",option);
822 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
824 ThrowAnimateException(OptionError,"UnrecognizedImageFilter",
828 if (LocaleCompare("flatten",option+1) == 0)
830 if (LocaleCompare("font",option+1) == 0)
835 if (i == (ssize_t) argc)
836 ThrowAnimateException(OptionError,"MissingArgument",option);
837 resource_info.font=XGetResourceClass(resource_database,
838 GetClientName(),"font",argv[i]);
841 if (LocaleCompare("foreground",option+1) == 0)
846 if (i == (ssize_t) argc)
847 ThrowAnimateException(OptionError,"MissingArgument",option);
848 resource_info.foreground_color=argv[i];
851 if (LocaleCompare("format",option+1) == 0)
856 if (i == (ssize_t) (argc-1))
857 ThrowAnimateException(OptionError,"MissingArgument",option);
860 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
864 if (LocaleCompare("gamma",option+1) == 0)
867 if (i == (ssize_t) argc)
868 ThrowAnimateException(OptionError,"MissingArgument",option);
869 if (IsGeometry(argv[i]) == MagickFalse)
870 ThrowAnimateInvalidArgumentException(option,argv[i]);
873 if (LocaleCompare("geometry",option+1) == 0)
875 resource_info.image_geometry=(char *) NULL;
879 if (i == (ssize_t) argc)
880 ThrowAnimateException(OptionError,"MissingArgument",option);
881 if (IsGeometry(argv[i]) == MagickFalse)
882 ThrowAnimateInvalidArgumentException(option,argv[i]);
883 resource_info.image_geometry=ConstantString(argv[i]);
886 if (LocaleCompare("gravity",option+1) == 0)
894 if (i == (ssize_t) (argc-1))
895 ThrowAnimateException(OptionError,"MissingArgument",option);
896 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
899 ThrowAnimateException(OptionError,"UnrecognizedGravityType",
903 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
907 if ((LocaleCompare("help",option+1) == 0) ||
908 (LocaleCompare("-help",option+1) == 0))
910 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
914 if (LocaleCompare("iconGeometry",option+1) == 0)
916 resource_info.icon_geometry=(char *) NULL;
920 if (i == (ssize_t) argc)
921 ThrowAnimateException(OptionError,"MissingArgument",option);
922 if (IsGeometry(argv[i]) == MagickFalse)
923 ThrowAnimateInvalidArgumentException(option,argv[i]);
924 resource_info.icon_geometry=argv[i];
927 if (LocaleCompare("iconic",option+1) == 0)
929 resource_info.iconic=(*option == '-') ? MagickTrue : MagickFalse;
932 if (LocaleCompare("identify",option+1) == 0)
934 if (LocaleCompare("immutable",option+1) == 0)
936 resource_info.immutable=(*option == '-') ? MagickTrue : MagickFalse;
939 if (LocaleCompare("interlace",option+1) == 0)
947 if (i == (ssize_t) argc)
948 ThrowAnimateException(OptionError,"MissingArgument",option);
949 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
952 ThrowAnimateException(OptionError,"UnrecognizedInterlaceType",
956 if (LocaleCompare("interpolate",option+1) == 0)
964 if (i == (ssize_t) argc)
965 ThrowAnimateException(OptionError,"MissingArgument",option);
966 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
969 ThrowAnimateException(OptionError,"UnrecognizedInterpolateMethod",
973 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
977 if (LocaleCompare("label",option+1) == 0)
982 if (i == (ssize_t) argc)
983 ThrowAnimateException(OptionError,"MissingArgument",option);
986 if (LocaleCompare("limit",option+1) == 0)
1000 if (i == (ssize_t) argc)
1001 ThrowAnimateException(OptionError,"MissingArgument",option);
1002 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
1005 ThrowAnimateException(OptionError,"UnrecognizedResourceType",
1008 if (i == (ssize_t) argc)
1009 ThrowAnimateException(OptionError,"MissingArgument",option);
1010 value=InterpretLocaleValue(argv[i],&p);
1012 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
1013 ThrowAnimateInvalidArgumentException(option,argv[i]);
1016 if (LocaleCompare("list",option+1) == 0)
1024 if (i == (ssize_t) argc)
1025 ThrowAnimateException(OptionError,"MissingArgument",option);
1026 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
1028 ThrowAnimateException(OptionError,"UnrecognizedListType",argv[i]);
1029 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
1032 return(status != 0 ? MagickFalse : MagickTrue);
1034 if (LocaleCompare("log",option+1) == 0)
1039 if ((i == (ssize_t) argc) ||
1040 (strchr(argv[i],'%') == (char *) NULL))
1041 ThrowAnimateException(OptionError,"MissingArgument",option);
1044 if (LocaleCompare("loop",option+1) == 0)
1049 if (i == (ssize_t) (argc-1))
1050 ThrowAnimateException(OptionError,"MissingArgument",option);
1051 if (IsGeometry(argv[i]) == MagickFalse)
1052 ThrowAnimateInvalidArgumentException(option,argv[i]);
1055 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1059 if (LocaleCompare("map",option+1) == 0)
1061 resource_info.map_type=(char *) NULL;
1064 (void) CopyMagickString(argv[i]+1,"san",MaxTextExtent);
1066 if (i == (ssize_t) argc)
1067 ThrowAnimateException(OptionError,"MissingArgument",option);
1068 resource_info.map_type=argv[i];
1071 if (LocaleCompare("matte",option+1) == 0)
1073 if (LocaleCompare("mattecolor",option+1) == 0)
1078 if (i == (ssize_t) argc)
1079 ThrowAnimateException(OptionError,"MissingArgument",option);
1080 resource_info.matte_color=argv[i];
1083 if (LocaleCompare("monitor",option+1) == 0)
1085 if (LocaleCompare("monochrome",option+1) == 0)
1089 quantize_info->number_colors=2;
1090 quantize_info->colorspace=GRAYColorspace;
1093 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1097 if (LocaleCompare("name",option+1) == 0)
1099 resource_info.name=(char *) NULL;
1103 if (i == (ssize_t) argc)
1104 ThrowAnimateException(OptionError,"MissingArgument",option);
1105 resource_info.name=ConstantString(argv[i]);
1108 if (LocaleCompare("noop",option+1) == 0)
1110 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1114 if (LocaleCompare("pause",option+1) == 0)
1116 resource_info.pause=0;
1120 if (i == (ssize_t) argc)
1121 ThrowAnimateException(OptionError,"MissingArgument",option);
1122 if (IsGeometry(argv[i]) == MagickFalse)
1123 ThrowAnimateInvalidArgumentException(option,argv[i]);
1124 resource_info.pause=(unsigned int) StringToUnsignedLong(argv[i]);
1127 if (LocaleCompare("page",option+1) == 0)
1132 if (i == (ssize_t) argc)
1133 ThrowAnimateException(OptionError,"MissingArgument",option);
1136 if (LocaleCompare("profile",option+1) == 0)
1139 if (i == (ssize_t) argc)
1140 ThrowAnimateException(OptionError,"MissingArgument",option);
1143 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1147 if (LocaleCompare("quantize",option+1) == 0)
1155 if (i == (ssize_t) (argc-1))
1156 ThrowAnimateException(OptionError,"MissingArgument",option);
1157 colorspace=ParseCommandOption(MagickColorspaceOptions,
1158 MagickFalse,argv[i]);
1160 ThrowAnimateException(OptionError,"UnrecognizedColorspace",
1164 if (LocaleCompare("quiet",option+1) == 0)
1166 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1170 if (LocaleCompare("regard-warnings",option+1) == 0)
1172 if (LocaleCompare("remote",option+1) == 0)
1175 if (i == (ssize_t) argc)
1176 ThrowAnimateException(OptionError,"MissingArgument",option);
1177 if (XRemoteCommand(display,resource_info.window_id,argv[i]) != 0)
1178 return(MagickFalse);
1182 if (LocaleCompare("repage",option+1) == 0)
1187 if (i == (ssize_t) argc)
1188 ThrowAnimateException(OptionError,"MissingArgument",option);
1189 if (IsGeometry(argv[i]) == MagickFalse)
1190 ThrowAnimateInvalidArgumentException(option,argv[i]);
1193 if (LocaleCompare("resample",option+1) == 0)
1198 if (i == (ssize_t) (argc-1))
1199 ThrowAnimateException(OptionError,"MissingArgument",option);
1200 if (IsGeometry(argv[i]) == MagickFalse)
1201 ThrowAnimateInvalidArgumentException(option,argv[i]);
1204 if (LocaleCompare("resize",option+1) == 0)
1209 if (i == (ssize_t) argc)
1210 ThrowAnimateException(OptionError,"MissingArgument",option);
1211 if (IsGeometry(argv[i]) == MagickFalse)
1212 ThrowAnimateInvalidArgumentException(option,argv[i]);
1215 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
1217 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
1220 if (LocaleCompare("rotate",option+1) == 0)
1223 if (i == (ssize_t) argc)
1224 ThrowAnimateException(OptionError,"MissingArgument",option);
1225 if (IsGeometry(argv[i]) == MagickFalse)
1226 ThrowAnimateInvalidArgumentException(option,argv[i]);
1229 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1233 if (LocaleCompare("sampling-factor",option+1) == 0)
1238 if (i == (ssize_t) argc)
1239 ThrowAnimateException(OptionError,"MissingArgument",option);
1240 if (IsGeometry(argv[i]) == MagickFalse)
1241 ThrowAnimateInvalidArgumentException(option,argv[i]);
1244 if (LocaleCompare("seed",option+1) == 0)
1249 if (i == (ssize_t) (argc-1))
1250 ThrowAnimateException(OptionError,"MissingArgument",option);
1251 if (IsGeometry(argv[i]) == MagickFalse)
1252 ThrowAnimateInvalidArgumentException(option,argv[i]);
1255 if (LocaleCompare("scenes",option+1) == 0) /* deprecated */
1260 if (i == (ssize_t) argc)
1261 ThrowAnimateException(OptionError,"MissingArgument",option);
1262 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
1263 ThrowAnimateInvalidArgumentException(option,argv[i]);
1266 if (LocaleCompare("set",option+1) == 0)
1269 if (i == (ssize_t) argc)
1270 ThrowAnimateException(OptionError,"MissingArgument",option);
1274 if (i == (ssize_t) argc)
1275 ThrowAnimateException(OptionError,"MissingArgument",option);
1278 if (LocaleCompare("shared-memory",option+1) == 0)
1280 resource_info.use_shared_memory=(*option == '-') ? MagickTrue :
1284 if (LocaleCompare("size",option+1) == 0)
1289 if (i == (ssize_t) argc)
1290 ThrowAnimateException(OptionError,"MissingArgument",option);
1291 if (IsGeometry(argv[i]) == MagickFalse)
1292 ThrowAnimateInvalidArgumentException(option,argv[i]);
1295 if (LocaleCompare("strip",option+1) == 0)
1297 if (LocaleCompare("support",option+1) == 0)
1299 i++; /* deprecated */
1302 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1306 if (LocaleCompare("text-font",option+1) == 0)
1308 resource_info.text_font=(char *) NULL;
1312 if (i == (ssize_t) argc)
1313 ThrowAnimateException(OptionError,"MissingArgument",option);
1314 resource_info.text_font=XGetResourceClass(resource_database,
1315 GetClientName(),"font",argv[i]);
1318 if (LocaleCompare("thumbnail",option+1) == 0)
1323 if (i == (ssize_t) argc)
1324 ThrowAnimateException(OptionError,"MissingArgument",option);
1325 if (IsGeometry(argv[i]) == MagickFalse)
1326 ThrowAnimateInvalidArgumentException(option,argv[i]);
1329 if (LocaleCompare("title",option+1) == 0)
1331 resource_info.title=(char *) NULL;
1335 if (i == (ssize_t) argc)
1336 ThrowAnimateException(OptionError,"MissingArgument",option);
1337 resource_info.title=argv[i];
1340 if (LocaleCompare("transparent-color",option+1) == 0)
1345 if (i == (ssize_t) (argc-1))
1346 ThrowAnimateException(OptionError,"MissingArgument",option);
1349 if (LocaleCompare("treedepth",option+1) == 0)
1351 quantize_info->tree_depth=0;
1355 if (i == (ssize_t) argc)
1356 ThrowAnimateException(OptionError,"MissingArgument",option);
1357 if (IsGeometry(argv[i]) == MagickFalse)
1358 ThrowAnimateInvalidArgumentException(option,argv[i]);
1359 quantize_info->tree_depth=StringToUnsignedLong(argv[i]);
1362 if (LocaleCompare("trim",option+1) == 0)
1364 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1368 if (LocaleCompare("verbose",option+1) == 0)
1370 if ((LocaleCompare("version",option+1) == 0) ||
1371 (LocaleCompare("-version",option+1) == 0))
1373 (void) FormatLocaleFile(stdout,"Version: %s\n",
1374 GetMagickVersion((size_t *) NULL));
1375 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
1376 GetMagickCopyright());
1377 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
1378 GetMagickFeatures());
1381 if (LocaleCompare("virtual-pixel",option+1) == 0)
1389 if (i == (ssize_t) argc)
1390 ThrowAnimateException(OptionError,"MissingArgument",option);
1391 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
1394 ThrowAnimateException(OptionError,
1395 "UnrecognizedVirtualPixelMethod",argv[i]);
1398 if (LocaleCompare("visual",option+1) == 0)
1400 resource_info.visual_type=(char *) NULL;
1404 if (i == (ssize_t) argc)
1405 ThrowAnimateException(OptionError,"MissingArgument",option);
1406 resource_info.visual_type=argv[i];
1409 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1413 if (LocaleCompare("window",option+1) == 0)
1415 resource_info.window_id=(char *) NULL;
1419 if (i == (ssize_t) argc)
1420 ThrowAnimateException(OptionError,"MissingArgument",option);
1421 resource_info.window_id=argv[i];
1424 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1429 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1431 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
1432 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
1433 if (fire != MagickFalse)
1434 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
1438 ThrowAnimateException(OptionError,"UnbalancedParenthesis",argv[i]);
1439 if (image == (Image *) NULL)
1440 ThrowAnimateException(OptionError,"MissingAnImageFilename",argv[argc-1])
1441 FinalizeImageSettings(image_info,image,MagickTrue);
1442 if (image == (Image *) NULL)
1443 ThrowAnimateException(OptionError,"MissingAnImageFilename",argv[argc-1])
1444 if (resource_info.window_id != (char *) NULL)
1446 XAnimateBackgroundImage(display,&resource_info,image,exception);
1455 Animate image to X server.
1457 animate_image=XAnimateImages(display,&resource_info,argv,argc,image,
1459 status&=animate_image != (Image *) NULL;
1460 while (animate_image != (Image *) NULL)
1462 image=animate_image;
1463 animate_image=XAnimateImages(display,&resource_info,argv,argc,image,
1465 if (animate_image != image)
1466 image=DestroyImageList(image);
1470 return(status != 0 ? MagickTrue : MagickFalse);
1474 (void) ThrowMagickException(exception,GetMagickModule(),MissingDelegateError,
1475 "DelegateLibrarySupportNotBuiltIn","`%s' (X11)",image_info->filename);
1476 return(AnimateUsage());