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"
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 "-map type display image using this Standard Colormap",
159 "-monitor monitor progress",
160 "-pause seconds to pause before reanimating",
161 "-page geometry size and location of an image canvas (setting)",
162 "-quantize colorspace reduce colors in this colorspace",
163 "-quiet suppress all warning messages",
164 "-regard-warnings pay attention to warning messages",
165 "-remote command execute a command in an remote display process",
166 "-respect-parentheses settings remain in effect until parenthesis boundary",
167 "-sampling-factor geometry",
168 " horizontal and vertical sampling factor",
169 "-seed value seed a new sequence of pseudo-random numbers",
170 "-set attribute value set an image attribute",
171 "-size geometry width and height of image",
172 "-transparent-color color",
173 " transparent color",
174 "-treedepth value color tree depth",
175 "-verbose print detailed information about the image",
176 "-visual type display image using this visual type",
177 "-virtual-pixel method",
178 " virtual pixel access method",
179 "-window id display image to background of this window",
182 *sequence_operators[]=
184 "-coalesce merge a sequence of images",
185 "-flatten flatten a sequence of images",
189 (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
190 (void) printf("Copyright: %s\n",GetMagickCopyright());
191 (void) printf("Features: %s\n\n",GetMagickFeatures());
192 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
194 (void) printf("\nImage Settings:\n");
195 for (p=settings; *p != (char *) NULL; p++)
196 (void) printf(" %s\n",*p);
197 (void) printf("\nImage Operators:\n");
198 for (p=operators; *p != (char *) NULL; p++)
199 (void) printf(" %s\n",*p);
200 (void) printf("\nImage Sequence Operators:\n");
201 for (p=sequence_operators; *p != (char *) NULL; p++)
202 (void) printf(" %s\n",*p);
203 (void) printf("\nMiscellaneous Options:\n");
204 for (p=miscellaneous; *p != (char *) NULL; p++)
205 (void) printf(" %s\n",*p);
207 "\nIn addition to those listed above, you can specify these standard X\n");
209 "resources as command line options: -background, -bordercolor,\n");
211 "-borderwidth, -font, -foreground, -iconGeometry, -iconic, -name,\n");
212 (void) printf("-mattecolor, -shared-memory, or -title.\n");
214 "\nBy default, the image format of `file' is determined by its magic\n");
216 "number. To specify a particular image format, precede the filename\n");
218 "with an image format name and a colon (i.e. ps:image) or specify the\n");
220 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
221 (void) printf("'-' for standard input or output.\n");
222 (void) printf("\nButtons: \n");
223 for (p=buttons; *p != (char *) NULL; p++)
224 (void) printf(" %s\n",*p);
228 WandExport MagickBooleanType AnimateImageCommand(ImageInfo *image_info,
229 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
231 #if defined(MAGICKCORE_X11_DELEGATE)
232 #define DestroyAnimate() \
234 XDestroyResourceInfo(&resource_info); \
235 if (display != (Display *) NULL) \
237 XCloseDisplay(display); \
238 display=(Display *) NULL; \
240 XDestroyResourceInfo(&resource_info); \
241 DestroyImageStack(); \
242 for (i=0; i < (ssize_t) argc; i++) \
243 argv[i]=DestroyString(argv[i]); \
244 argv=(char **) RelinquishMagickMemory(argv); \
246 #define ThrowAnimateException(asperity,tag,option) \
248 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
251 return(MagickFalse); \
253 #define ThrowAnimateInvalidArgumentException(option,argument) \
255 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
256 "InvalidArgument","`%s': %s",option,argument); \
258 return(MagickFalse); \
275 image_stack[MaxImageStackDepth+1];
304 assert(image_info != (ImageInfo *) NULL);
305 assert(image_info->signature == MagickSignature);
306 if (image_info->debug != MagickFalse)
307 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
308 assert(exception != (ExceptionInfo *) NULL);
312 if ((LocaleCompare("version",option+1) == 0) ||
313 (LocaleCompare("-version",option+1) == 0))
315 (void) FormatLocaleFile(stdout,"Version: %s\n",
316 GetMagickVersion((size_t *) NULL));
317 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
318 GetMagickCopyright());
319 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
320 GetMagickFeatures());
326 display=(Display *) NULL;
330 option=(char *) NULL;
332 respect_parenthesis=MagickFalse;
333 resource_database=(XrmDatabase) NULL;
334 (void) ResetMagickMemory(&resource_info,0,sizeof(XResourceInfo));
335 server_name=(char *) NULL;
338 Check for server name specified on the command line.
340 ReadCommandlLine(argc,&argv);
341 status=ExpandFilenames(&argc,&argv);
342 if (status == MagickFalse)
343 ThrowAnimateException(ResourceLimitError,"MemoryAllocationFailed",
344 image_info->filename);
345 for (i=1; i < (ssize_t) argc; i++)
348 Check command line for server name.
351 if (LocaleCompare("display",option+1) == 0)
354 User specified server name.
357 if (i == (ssize_t) argc)
358 ThrowAnimateException(OptionError,"MissingArgument",option);
361 if ((LocaleCompare("help",option+1) == 0) ||
362 (LocaleCompare("-help",option+1) == 0))
363 return(AnimateUsage());
366 Get user defaults from X resource database.
368 display=XOpenDisplay(server_name);
369 if (display == (Display *) NULL)
370 ThrowAnimateException(XServerError,"UnableToOpenXServer",
371 XDisplayName(server_name));
372 (void) XSetErrorHandler(XError);
373 resource_database=XGetResourceDatabase(display,GetClientName());
374 XGetResourceInfo(image_info,resource_database,GetClientName(),
376 quantize_info=resource_info.quantize_info;
377 image_info->density=XGetResourceInstance(resource_database,GetClientName(),
378 "density",(char *) NULL);
379 if (image_info->density == (char *) NULL)
380 image_info->density=XGetScreenDensity(display);
381 resource_value=XGetResourceInstance(resource_database,GetClientName(),
383 image_info->interlace=(InterlaceType)
384 ParseCommandOption(MagickInterlaceOptions,MagickFalse,resource_value);
385 resource_value=XGetResourceInstance(resource_database,GetClientName(),
387 image_info->verbose=IsMagickTrue(resource_value);
388 resource_value=XGetResourceInstance(resource_database,GetClientName(),
390 quantize_info->dither=IsMagickTrue(resource_value);
394 for (i=1; i <= (ssize_t) argc; i++)
396 if (i < (ssize_t) argc)
399 if (image != (Image *) NULL)
402 if (isatty(STDIN_FILENO) != MagickFalse)
418 if (LocaleCompare(option,"(") == 0)
420 FireImageStack(MagickFalse,MagickTrue,pend);
421 if (k == MaxImageStackDepth)
422 ThrowAnimateException(OptionError,"ParenthesisNestedTooDeeply",
427 if (LocaleCompare(option,")") == 0)
429 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
431 ThrowAnimateException(OptionError,"UnableToParseExpression",option);
435 if (IsCommandOption(option) == MagickFalse)
446 FireImageStack(MagickFalse,MagickFalse,pend);
448 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
453 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
454 if (image_info->ping != MagickFalse)
455 images=PingImages(image_info,exception);
457 images=ReadImages(image_info,exception);
458 status&=(images != (Image *) NULL) &&
459 (exception->severity < ErrorException);
460 if (images == (Image *) NULL)
462 AppendImageStack(images);
465 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
470 if (LocaleCompare("alpha",option+1) == 0)
478 if (i == (ssize_t) argc)
479 ThrowAnimateException(OptionError,"MissingArgument",option);
480 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
482 ThrowAnimateException(OptionError,"UnrecognizedAlphaChannelType",
486 if (LocaleCompare("authenticate",option+1) == 0)
491 if (i == (ssize_t) argc)
492 ThrowAnimateException(OptionError,"MissingArgument",option);
495 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
499 if (LocaleCompare("backdrop",option+1) == 0)
501 resource_info.backdrop=(*option == '-') ? MagickTrue : MagickFalse;
504 if (LocaleCompare("background",option+1) == 0)
509 if (i == (ssize_t) argc)
510 ThrowAnimateException(OptionError,"MissingArgument",option);
511 resource_info.background_color=argv[i];
514 if (LocaleCompare("bordercolor",option+1) == 0)
519 if (i == (ssize_t) argc)
520 ThrowAnimateException(OptionError,"MissingArgument",option);
521 resource_info.border_color=argv[i];
524 if (LocaleCompare("borderwidth",option+1) == 0)
526 resource_info.border_width=0;
530 if ((i == (ssize_t) argc) || (IsGeometry(argv[i]) == MagickFalse))
531 ThrowAnimateException(OptionError,"MissingArgument",option);
532 resource_info.border_width=(unsigned int)
533 StringToUnsignedLong(argv[i]);
536 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
540 if (LocaleCompare("cache",option+1) == 0)
545 if (i == (ssize_t) argc)
546 ThrowAnimateException(OptionError,"MissingArgument",option);
547 if (IsGeometry(argv[i]) == MagickFalse)
548 ThrowAnimateInvalidArgumentException(option,argv[i]);
551 if (LocaleCompare("channel",option+1) == 0)
559 if (i == (ssize_t) (argc-1))
560 ThrowAnimateException(OptionError,"MissingArgument",option);
561 channel=ParseChannelOption(argv[i]);
563 ThrowAnimateException(OptionError,"UnrecognizedChannelType",
567 if (LocaleCompare("clone",option+1) == 0)
574 clone_images=image_stack[k-1].image;
575 if (clone_images == (Image *) NULL)
576 ThrowAnimateException(ImageError,"ImageSequenceRequired",option);
577 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
579 clone_images=CloneImages(clone_images,"-1",exception);
583 if (i == (ssize_t) (argc-1))
584 ThrowAnimateException(OptionError,"MissingArgument",option);
585 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
586 ThrowAnimateInvalidArgumentException(option,argv[i]);
587 clone_images=CloneImages(clone_images,argv[i],exception);
589 if (clone_images == (Image *) NULL)
590 ThrowAnimateException(OptionError,"NoSuchImage",option);
591 AppendImageStack(clone_images);
594 if (LocaleCompare("coalesce",option+1) == 0)
596 if (LocaleCompare("colormap",option+1) == 0)
598 resource_info.colormap=PrivateColormap;
602 if (i == (ssize_t) argc)
603 ThrowAnimateException(OptionError,"MissingArgument",option);
604 resource_info.colormap=UndefinedColormap;
605 if (LocaleCompare("private",argv[i]) == 0)
606 resource_info.colormap=PrivateColormap;
607 if (LocaleCompare("shared",argv[i]) == 0)
608 resource_info.colormap=SharedColormap;
609 if (resource_info.colormap == UndefinedColormap)
610 ThrowAnimateException(OptionError,"UnrecognizedColormapType",
614 if (LocaleCompare("colors",option+1) == 0)
616 quantize_info->number_colors=0;
620 if (i == (ssize_t) argc)
621 ThrowAnimateException(OptionError,"MissingArgument",option);
622 if (IsGeometry(argv[i]) == MagickFalse)
623 ThrowAnimateInvalidArgumentException(option,argv[i]);
624 quantize_info->number_colors=StringToUnsignedLong(argv[i]);
627 if (LocaleCompare("colorspace",option+1) == 0)
635 if (i == (ssize_t) argc)
636 ThrowAnimateException(OptionError,"MissingArgument",option);
637 colorspace=ParseCommandOption(MagickColorspaceOptions,
638 MagickFalse,argv[i]);
640 ThrowAnimateException(OptionError,"UnrecognizedColorspace",
644 if (LocaleCompare("concurrent",option+1) == 0)
646 if (LocaleCompare("crop",option+1) == 0)
651 if (i == (ssize_t) argc)
652 ThrowAnimateException(OptionError,"MissingArgument",option);
653 if (IsGeometry(argv[i]) == MagickFalse)
654 ThrowAnimateInvalidArgumentException(option,argv[i]);
657 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
661 if (LocaleCompare("debug",option+1) == 0)
669 if (i == (ssize_t) argc)
670 ThrowAnimateException(OptionError,"MissingArgument",option);
671 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
673 ThrowAnimateException(OptionError,"UnrecognizedEventType",
675 (void) SetLogEventMask(argv[i]);
678 if (LocaleCompare("decipher",option+1) == 0)
683 if (i == (ssize_t) (argc-1))
684 ThrowAnimateException(OptionError,"MissingArgument",option);
687 if (LocaleCompare("define",option+1) == 0)
690 if (i == (ssize_t) argc)
691 ThrowAnimateException(OptionError,"MissingArgument",option);
697 define=GetImageOption(image_info,argv[i]);
698 if (define == (const char *) NULL)
699 ThrowAnimateException(OptionError,"NoSuchOption",argv[i]);
704 if (LocaleCompare("delay",option+1) == 0)
709 if (i == (ssize_t) argc)
710 ThrowAnimateException(OptionError,"MissingArgument",option);
711 if (IsGeometry(argv[i]) == MagickFalse)
712 ThrowAnimateInvalidArgumentException(option,argv[i]);
715 if (LocaleCompare("density",option+1) == 0)
720 if (i == (ssize_t) argc)
721 ThrowAnimateException(OptionError,"MissingArgument",option);
722 if (IsGeometry(argv[i]) == MagickFalse)
723 ThrowAnimateInvalidArgumentException(option,argv[i]);
726 if (LocaleCompare("depth",option+1) == 0)
731 if (i == (ssize_t) argc)
732 ThrowAnimateException(OptionError,"MissingArgument",option);
733 if (IsGeometry(argv[i]) == MagickFalse)
734 ThrowAnimateInvalidArgumentException(option,argv[i]);
737 if (LocaleCompare("display",option+1) == 0)
742 if (i == (ssize_t) argc)
743 ThrowAnimateException(OptionError,"MissingArgument",option);
746 if (LocaleCompare("dispose",option+1) == 0)
754 if (i == (ssize_t) argc)
755 ThrowAnimateException(OptionError,"MissingArgument",option);
756 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
758 ThrowAnimateException(OptionError,"UnrecognizedDisposeMethod",
762 if (LocaleCompare("dither",option+1) == 0)
767 quantize_info->dither=MagickFalse;
771 if (i == (ssize_t) argc)
772 ThrowAnimateException(OptionError,"MissingArgument",option);
773 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
775 ThrowAnimateException(OptionError,"UnrecognizedDitherMethod",
777 quantize_info->dither=MagickTrue;
778 quantize_info->dither_method=(DitherMethod) method;
781 if (LocaleCompare("duration",option+1) == 0)
786 if (i == (ssize_t) (argc-1))
787 ThrowAnimateException(OptionError,"MissingArgument",option);
788 if (IsGeometry(argv[i]) == MagickFalse)
789 ThrowAnimateInvalidArgumentException(option,argv[i]);
792 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
796 if (LocaleCompare("extract",option+1) == 0)
801 if (i == (ssize_t) argc)
802 ThrowAnimateException(OptionError,"MissingArgument",option);
803 if (IsGeometry(argv[i]) == MagickFalse)
804 ThrowAnimateInvalidArgumentException(option,argv[i]);
807 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
811 if (LocaleCompare("filter",option+1) == 0)
819 if (i == (ssize_t) (argc-1))
820 ThrowAnimateException(OptionError,"MissingArgument",option);
821 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
823 ThrowAnimateException(OptionError,"UnrecognizedImageFilter",
827 if (LocaleCompare("flatten",option+1) == 0)
829 if (LocaleCompare("font",option+1) == 0)
834 if (i == (ssize_t) argc)
835 ThrowAnimateException(OptionError,"MissingArgument",option);
836 resource_info.font=XGetResourceClass(resource_database,
837 GetClientName(),"font",argv[i]);
840 if (LocaleCompare("foreground",option+1) == 0)
845 if (i == (ssize_t) argc)
846 ThrowAnimateException(OptionError,"MissingArgument",option);
847 resource_info.foreground_color=argv[i];
850 if (LocaleCompare("format",option+1) == 0)
855 if (i == (ssize_t) (argc-1))
856 ThrowAnimateException(OptionError,"MissingArgument",option);
859 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
863 if (LocaleCompare("gamma",option+1) == 0)
866 if (i == (ssize_t) argc)
867 ThrowAnimateException(OptionError,"MissingArgument",option);
868 if (IsGeometry(argv[i]) == MagickFalse)
869 ThrowAnimateInvalidArgumentException(option,argv[i]);
872 if (LocaleCompare("geometry",option+1) == 0)
874 resource_info.image_geometry=(char *) NULL;
878 if (i == (ssize_t) argc)
879 ThrowAnimateException(OptionError,"MissingArgument",option);
880 if (IsGeometry(argv[i]) == MagickFalse)
881 ThrowAnimateInvalidArgumentException(option,argv[i]);
882 resource_info.image_geometry=ConstantString(argv[i]);
885 if (LocaleCompare("gravity",option+1) == 0)
893 if (i == (ssize_t) (argc-1))
894 ThrowAnimateException(OptionError,"MissingArgument",option);
895 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
898 ThrowAnimateException(OptionError,"UnrecognizedGravityType",
902 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
906 if ((LocaleCompare("help",option+1) == 0) ||
907 (LocaleCompare("-help",option+1) == 0))
909 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
913 if (LocaleCompare("iconGeometry",option+1) == 0)
915 resource_info.icon_geometry=(char *) NULL;
919 if (i == (ssize_t) argc)
920 ThrowAnimateException(OptionError,"MissingArgument",option);
921 if (IsGeometry(argv[i]) == MagickFalse)
922 ThrowAnimateInvalidArgumentException(option,argv[i]);
923 resource_info.icon_geometry=argv[i];
926 if (LocaleCompare("iconic",option+1) == 0)
928 resource_info.iconic=(*option == '-') ? MagickTrue : MagickFalse;
931 if (LocaleCompare("identify",option+1) == 0)
933 if (LocaleCompare("immutable",option+1) == 0)
935 resource_info.immutable=(*option == '-') ? MagickTrue : MagickFalse;
938 if (LocaleCompare("interlace",option+1) == 0)
946 if (i == (ssize_t) argc)
947 ThrowAnimateException(OptionError,"MissingArgument",option);
948 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
951 ThrowAnimateException(OptionError,"UnrecognizedInterlaceType",
955 if (LocaleCompare("interpolate",option+1) == 0)
963 if (i == (ssize_t) argc)
964 ThrowAnimateException(OptionError,"MissingArgument",option);
965 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
968 ThrowAnimateException(OptionError,"UnrecognizedInterpolateMethod",
972 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
976 if (LocaleCompare("label",option+1) == 0)
981 if (i == (ssize_t) argc)
982 ThrowAnimateException(OptionError,"MissingArgument",option);
985 if (LocaleCompare("limit",option+1) == 0)
999 if (i == (ssize_t) argc)
1000 ThrowAnimateException(OptionError,"MissingArgument",option);
1001 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
1004 ThrowAnimateException(OptionError,"UnrecognizedResourceType",
1007 if (i == (ssize_t) argc)
1008 ThrowAnimateException(OptionError,"MissingArgument",option);
1009 value=InterpretLocaleValue(argv[i],&p);
1011 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
1012 ThrowAnimateInvalidArgumentException(option,argv[i]);
1015 if (LocaleCompare("list",option+1) == 0)
1023 if (i == (ssize_t) argc)
1024 ThrowAnimateException(OptionError,"MissingArgument",option);
1025 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
1027 ThrowAnimateException(OptionError,"UnrecognizedListType",argv[i]);
1028 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
1031 return(status != 0 ? MagickFalse : MagickTrue);
1033 if (LocaleCompare("log",option+1) == 0)
1038 if ((i == (ssize_t) argc) ||
1039 (strchr(argv[i],'%') == (char *) NULL))
1040 ThrowAnimateException(OptionError,"MissingArgument",option);
1043 if (LocaleCompare("loop",option+1) == 0)
1048 if (i == (ssize_t) (argc-1))
1049 ThrowAnimateException(OptionError,"MissingArgument",option);
1050 if (IsGeometry(argv[i]) == MagickFalse)
1051 ThrowAnimateInvalidArgumentException(option,argv[i]);
1054 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1058 if (LocaleCompare("map",option+1) == 0)
1060 resource_info.map_type=(char *) NULL;
1063 (void) CopyMagickString(argv[i]+1,"san",MaxTextExtent);
1065 if (i == (ssize_t) argc)
1066 ThrowAnimateException(OptionError,"MissingArgument",option);
1067 resource_info.map_type=argv[i];
1070 if (LocaleCompare("matte",option+1) == 0)
1072 if (LocaleCompare("mattecolor",option+1) == 0)
1077 if (i == (ssize_t) argc)
1078 ThrowAnimateException(OptionError,"MissingArgument",option);
1079 resource_info.matte_color=argv[i];
1082 if (LocaleCompare("monitor",option+1) == 0)
1084 if (LocaleCompare("monochrome",option+1) == 0)
1088 quantize_info->number_colors=2;
1089 quantize_info->colorspace=GRAYColorspace;
1092 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1096 if (LocaleCompare("name",option+1) == 0)
1098 resource_info.name=(char *) NULL;
1102 if (i == (ssize_t) argc)
1103 ThrowAnimateException(OptionError,"MissingArgument",option);
1104 resource_info.name=ConstantString(argv[i]);
1107 if (LocaleCompare("noop",option+1) == 0)
1109 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1113 if (LocaleCompare("pause",option+1) == 0)
1115 resource_info.pause=0;
1119 if (i == (ssize_t) argc)
1120 ThrowAnimateException(OptionError,"MissingArgument",option);
1121 if (IsGeometry(argv[i]) == MagickFalse)
1122 ThrowAnimateInvalidArgumentException(option,argv[i]);
1123 resource_info.pause=(unsigned int) StringToUnsignedLong(argv[i]);
1126 if (LocaleCompare("page",option+1) == 0)
1131 if (i == (ssize_t) argc)
1132 ThrowAnimateException(OptionError,"MissingArgument",option);
1135 if (LocaleCompare("profile",option+1) == 0)
1138 if (i == (ssize_t) argc)
1139 ThrowAnimateException(OptionError,"MissingArgument",option);
1142 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1146 if (LocaleCompare("quantize",option+1) == 0)
1154 if (i == (ssize_t) (argc-1))
1155 ThrowAnimateException(OptionError,"MissingArgument",option);
1156 colorspace=ParseCommandOption(MagickColorspaceOptions,
1157 MagickFalse,argv[i]);
1159 ThrowAnimateException(OptionError,"UnrecognizedColorspace",
1163 if (LocaleCompare("quiet",option+1) == 0)
1165 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1169 if (LocaleCompare("regard-warnings",option+1) == 0)
1171 if (LocaleCompare("remote",option+1) == 0)
1174 if (i == (ssize_t) argc)
1175 ThrowAnimateException(OptionError,"MissingArgument",option);
1176 if (XRemoteCommand(display,resource_info.window_id,argv[i]) != 0)
1177 return(MagickFalse);
1181 if (LocaleCompare("repage",option+1) == 0)
1186 if (i == (ssize_t) argc)
1187 ThrowAnimateException(OptionError,"MissingArgument",option);
1188 if (IsGeometry(argv[i]) == MagickFalse)
1189 ThrowAnimateInvalidArgumentException(option,argv[i]);
1192 if (LocaleCompare("resample",option+1) == 0)
1197 if (i == (ssize_t) (argc-1))
1198 ThrowAnimateException(OptionError,"MissingArgument",option);
1199 if (IsGeometry(argv[i]) == MagickFalse)
1200 ThrowAnimateInvalidArgumentException(option,argv[i]);
1203 if (LocaleCompare("resize",option+1) == 0)
1208 if (i == (ssize_t) argc)
1209 ThrowAnimateException(OptionError,"MissingArgument",option);
1210 if (IsGeometry(argv[i]) == MagickFalse)
1211 ThrowAnimateInvalidArgumentException(option,argv[i]);
1214 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
1216 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
1219 if (LocaleCompare("rotate",option+1) == 0)
1222 if (i == (ssize_t) argc)
1223 ThrowAnimateException(OptionError,"MissingArgument",option);
1224 if (IsGeometry(argv[i]) == MagickFalse)
1225 ThrowAnimateInvalidArgumentException(option,argv[i]);
1228 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1232 if (LocaleCompare("sampling-factor",option+1) == 0)
1237 if (i == (ssize_t) argc)
1238 ThrowAnimateException(OptionError,"MissingArgument",option);
1239 if (IsGeometry(argv[i]) == MagickFalse)
1240 ThrowAnimateInvalidArgumentException(option,argv[i]);
1243 if (LocaleCompare("seed",option+1) == 0)
1248 if (i == (ssize_t) (argc-1))
1249 ThrowAnimateException(OptionError,"MissingArgument",option);
1250 if (IsGeometry(argv[i]) == MagickFalse)
1251 ThrowAnimateInvalidArgumentException(option,argv[i]);
1254 if (LocaleCompare("scenes",option+1) == 0) /* deprecated */
1259 if (i == (ssize_t) argc)
1260 ThrowAnimateException(OptionError,"MissingArgument",option);
1261 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
1262 ThrowAnimateInvalidArgumentException(option,argv[i]);
1265 if (LocaleCompare("set",option+1) == 0)
1268 if (i == (ssize_t) argc)
1269 ThrowAnimateException(OptionError,"MissingArgument",option);
1273 if (i == (ssize_t) argc)
1274 ThrowAnimateException(OptionError,"MissingArgument",option);
1277 if (LocaleCompare("shared-memory",option+1) == 0)
1279 resource_info.use_shared_memory=(*option == '-') ? MagickTrue :
1283 if (LocaleCompare("size",option+1) == 0)
1288 if (i == (ssize_t) argc)
1289 ThrowAnimateException(OptionError,"MissingArgument",option);
1290 if (IsGeometry(argv[i]) == MagickFalse)
1291 ThrowAnimateInvalidArgumentException(option,argv[i]);
1294 if (LocaleCompare("strip",option+1) == 0)
1296 if (LocaleCompare("support",option+1) == 0)
1298 i++; /* deprecated */
1301 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1305 if (LocaleCompare("text-font",option+1) == 0)
1307 resource_info.text_font=(char *) NULL;
1311 if (i == (ssize_t) argc)
1312 ThrowAnimateException(OptionError,"MissingArgument",option);
1313 resource_info.text_font=XGetResourceClass(resource_database,
1314 GetClientName(),"font",argv[i]);
1317 if (LocaleCompare("thumbnail",option+1) == 0)
1322 if (i == (ssize_t) argc)
1323 ThrowAnimateException(OptionError,"MissingArgument",option);
1324 if (IsGeometry(argv[i]) == MagickFalse)
1325 ThrowAnimateInvalidArgumentException(option,argv[i]);
1328 if (LocaleCompare("title",option+1) == 0)
1330 resource_info.title=(char *) NULL;
1334 if (i == (ssize_t) argc)
1335 ThrowAnimateException(OptionError,"MissingArgument",option);
1336 resource_info.title=argv[i];
1339 if (LocaleCompare("transparent-color",option+1) == 0)
1344 if (i == (ssize_t) (argc-1))
1345 ThrowAnimateException(OptionError,"MissingArgument",option);
1348 if (LocaleCompare("treedepth",option+1) == 0)
1350 quantize_info->tree_depth=0;
1354 if (i == (ssize_t) argc)
1355 ThrowAnimateException(OptionError,"MissingArgument",option);
1356 if (IsGeometry(argv[i]) == MagickFalse)
1357 ThrowAnimateInvalidArgumentException(option,argv[i]);
1358 quantize_info->tree_depth=StringToUnsignedLong(argv[i]);
1361 if (LocaleCompare("trim",option+1) == 0)
1363 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1367 if (LocaleCompare("verbose",option+1) == 0)
1369 if ((LocaleCompare("version",option+1) == 0) ||
1370 (LocaleCompare("-version",option+1) == 0))
1372 (void) FormatLocaleFile(stdout,"Version: %s\n",
1373 GetMagickVersion((size_t *) NULL));
1374 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
1375 GetMagickCopyright());
1376 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
1377 GetMagickFeatures());
1380 if (LocaleCompare("virtual-pixel",option+1) == 0)
1388 if (i == (ssize_t) argc)
1389 ThrowAnimateException(OptionError,"MissingArgument",option);
1390 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
1393 ThrowAnimateException(OptionError,
1394 "UnrecognizedVirtualPixelMethod",argv[i]);
1397 if (LocaleCompare("visual",option+1) == 0)
1399 resource_info.visual_type=(char *) NULL;
1403 if (i == (ssize_t) argc)
1404 ThrowAnimateException(OptionError,"MissingArgument",option);
1405 resource_info.visual_type=argv[i];
1408 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1412 if (LocaleCompare("window",option+1) == 0)
1414 resource_info.window_id=(char *) NULL;
1418 if (i == (ssize_t) argc)
1419 ThrowAnimateException(OptionError,"MissingArgument",option);
1420 resource_info.window_id=argv[i];
1423 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1428 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1430 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
1431 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
1432 if (fire != MagickFalse)
1433 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
1437 ThrowAnimateException(OptionError,"UnbalancedParenthesis",argv[i]);
1438 if (image == (Image *) NULL)
1439 ThrowAnimateException(OptionError,"MissingAnImageFilename",argv[argc-1])
1440 FinalizeImageSettings(image_info,image,MagickTrue);
1441 if (image == (Image *) NULL)
1442 ThrowAnimateException(OptionError,"MissingAnImageFilename",argv[argc-1])
1443 if (resource_info.window_id != (char *) NULL)
1445 XAnimateBackgroundImage(display,&resource_info,image);
1454 Animate image to X server.
1456 animate_image=XAnimateImages(display,&resource_info,argv,argc,image);
1457 status&=animate_image != (Image *) NULL;
1458 while (animate_image != (Image *) NULL)
1460 image=animate_image;
1461 animate_image=XAnimateImages(display,&resource_info,argv,argc,image);
1462 if (animate_image != image)
1463 image=DestroyImageList(image);
1467 return(status != 0 ? MagickTrue : MagickFalse);
1471 (void) ThrowMagickException(exception,GetMagickModule(),MissingDelegateError,
1472 "DelegateLibrarySupportNotBuiltIn","`%s' (X11)",image_info->filename);
1473 return(AnimateUsage());