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 "wand/studio.h"
44 #include "wand/MagickWand.h"
45 #include "wand/mogrify-private.h"
46 #include "magick/animate-private.h"
47 #include "magick/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];
303 assert(image_info != (ImageInfo *) NULL);
304 assert(image_info->signature == MagickSignature);
305 if (image_info->debug != MagickFalse)
306 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
307 assert(exception != (ExceptionInfo *) NULL);
311 if ((LocaleCompare("version",option+1) == 0) ||
312 (LocaleCompare("-version",option+1) == 0))
314 (void) fprintf(stdout,"Version: %s\n",
315 GetMagickVersion((size_t *) NULL));
316 (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
317 (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
323 display=(Display *) NULL;
327 option=(char *) NULL;
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 ParseMagickOption(MagickInterlaceOptions,MagickFalse,resource_value);
381 resource_value=XGetResourceInstance(resource_database,GetClientName(),
383 image_info->verbose=IsMagickTrue(resource_value);
384 resource_value=XGetResourceInstance(resource_database,GetClientName(),
386 quantize_info->dither=IsMagickTrue(resource_value);
390 for (i=1; i <= (ssize_t) argc; i++)
392 if (i < (ssize_t) argc)
395 if (image != (Image *) NULL)
398 if (isatty(STDIN_FILENO) != MagickFalse)
414 if (LocaleCompare(option,"(") == 0)
416 FireImageStack(MagickFalse,MagickTrue,pend);
417 if (k == MaxImageStackDepth)
418 ThrowAnimateException(OptionError,"ParenthesisNestedTooDeeply",
423 if (LocaleCompare(option,")") == 0)
425 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
427 ThrowAnimateException(OptionError,"UnableToParseExpression",option);
431 if (IsMagickOption(option) == MagickFalse)
442 FireImageStack(MagickFalse,MagickFalse,pend);
444 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
449 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
450 if (image_info->ping != MagickFalse)
451 images=PingImages(image_info,exception);
453 images=ReadImages(image_info,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=ParseMagickOption(MagickAlphaOptions,MagickFalse,argv[i]);
478 ThrowAnimateException(OptionError,"UnrecognizedAlphaChannelType",
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-1))
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,"ImageSequenceRequired",option);
573 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
575 clone_images=CloneImages(clone_images,"-1",exception);
579 if (i == (ssize_t) (argc-1))
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=ParseMagickOption(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=ParseMagickOption(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-1))
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=ParseMagickOption(MagickDisposeOptions,MagickFalse,argv[i]);
754 ThrowAnimateException(OptionError,"UnrecognizedDisposeMethod",
758 if (LocaleCompare("dither",option+1) == 0)
763 quantize_info->dither=MagickFalse;
767 if (i == (ssize_t) argc)
768 ThrowAnimateException(OptionError,"MissingArgument",option);
769 method=ParseMagickOption(MagickDitherOptions,MagickFalse,argv[i]);
771 ThrowAnimateException(OptionError,"UnrecognizedDitherMethod",
773 quantize_info->dither=MagickTrue;
774 quantize_info->dither_method=(DitherMethod) method;
777 if (LocaleCompare("duration",option+1) == 0)
782 if (i == (ssize_t) (argc-1))
783 ThrowAnimateException(OptionError,"MissingArgument",option);
784 if (IsGeometry(argv[i]) == MagickFalse)
785 ThrowAnimateInvalidArgumentException(option,argv[i]);
788 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
792 if (LocaleCompare("extract",option+1) == 0)
797 if (i == (ssize_t) argc)
798 ThrowAnimateException(OptionError,"MissingArgument",option);
799 if (IsGeometry(argv[i]) == MagickFalse)
800 ThrowAnimateInvalidArgumentException(option,argv[i]);
803 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
807 if (LocaleCompare("filter",option+1) == 0)
815 if (i == (ssize_t) (argc-1))
816 ThrowAnimateException(OptionError,"MissingArgument",option);
817 filter=ParseMagickOption(MagickFilterOptions,MagickFalse,argv[i]);
819 ThrowAnimateException(OptionError,"UnrecognizedImageFilter",
823 if (LocaleCompare("flatten",option+1) == 0)
825 if (LocaleCompare("font",option+1) == 0)
830 if (i == (ssize_t) argc)
831 ThrowAnimateException(OptionError,"MissingArgument",option);
832 resource_info.font=XGetResourceClass(resource_database,
833 GetClientName(),"font",argv[i]);
836 if (LocaleCompare("foreground",option+1) == 0)
841 if (i == (ssize_t) argc)
842 ThrowAnimateException(OptionError,"MissingArgument",option);
843 resource_info.foreground_color=argv[i];
846 if (LocaleCompare("format",option+1) == 0)
851 if (i == (ssize_t) (argc-1))
852 ThrowAnimateException(OptionError,"MissingArgument",option);
855 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
859 if (LocaleCompare("gamma",option+1) == 0)
862 if (i == (ssize_t) argc)
863 ThrowAnimateException(OptionError,"MissingArgument",option);
864 if (IsGeometry(argv[i]) == MagickFalse)
865 ThrowAnimateInvalidArgumentException(option,argv[i]);
868 if (LocaleCompare("geometry",option+1) == 0)
870 resource_info.image_geometry=(char *) NULL;
874 if (i == (ssize_t) argc)
875 ThrowAnimateException(OptionError,"MissingArgument",option);
876 if (IsGeometry(argv[i]) == MagickFalse)
877 ThrowAnimateInvalidArgumentException(option,argv[i]);
878 resource_info.image_geometry=ConstantString(argv[i]);
881 if (LocaleCompare("gravity",option+1) == 0)
889 if (i == (ssize_t) (argc-1))
890 ThrowAnimateException(OptionError,"MissingArgument",option);
891 gravity=ParseMagickOption(MagickGravityOptions,MagickFalse,
894 ThrowAnimateException(OptionError,"UnrecognizedGravityType",
898 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
902 if ((LocaleCompare("help",option+1) == 0) ||
903 (LocaleCompare("-help",option+1) == 0))
905 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
909 if (LocaleCompare("iconGeometry",option+1) == 0)
911 resource_info.icon_geometry=(char *) NULL;
915 if (i == (ssize_t) argc)
916 ThrowAnimateException(OptionError,"MissingArgument",option);
917 if (IsGeometry(argv[i]) == MagickFalse)
918 ThrowAnimateInvalidArgumentException(option,argv[i]);
919 resource_info.icon_geometry=argv[i];
922 if (LocaleCompare("iconic",option+1) == 0)
924 resource_info.iconic=(*option == '-') ? MagickTrue : MagickFalse;
927 if (LocaleCompare("identify",option+1) == 0)
929 if (LocaleCompare("immutable",option+1) == 0)
931 resource_info.immutable=(*option == '-') ? MagickTrue : MagickFalse;
934 if (LocaleCompare("interlace",option+1) == 0)
942 if (i == (ssize_t) argc)
943 ThrowAnimateException(OptionError,"MissingArgument",option);
944 interlace=ParseMagickOption(MagickInterlaceOptions,MagickFalse,
947 ThrowAnimateException(OptionError,"UnrecognizedInterlaceType",
951 if (LocaleCompare("interpolate",option+1) == 0)
959 if (i == (ssize_t) argc)
960 ThrowAnimateException(OptionError,"MissingArgument",option);
961 interpolate=ParseMagickOption(MagickInterpolateOptions,MagickFalse,
964 ThrowAnimateException(OptionError,"UnrecognizedInterpolateMethod",
968 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
972 if (LocaleCompare("label",option+1) == 0)
977 if (i == (ssize_t) argc)
978 ThrowAnimateException(OptionError,"MissingArgument",option);
981 if (LocaleCompare("limit",option+1) == 0)
995 if (i == (ssize_t) argc)
996 ThrowAnimateException(OptionError,"MissingArgument",option);
997 resource=ParseMagickOption(MagickResourceOptions,MagickFalse,
1000 ThrowAnimateException(OptionError,"UnrecognizedResourceType",
1003 if (i == (ssize_t) argc)
1004 ThrowAnimateException(OptionError,"MissingArgument",option);
1005 value=strtod(argv[i],&p);
1007 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
1008 ThrowAnimateInvalidArgumentException(option,argv[i]);
1011 if (LocaleCompare("list",option+1) == 0)
1019 if (i == (ssize_t) argc)
1020 ThrowAnimateException(OptionError,"MissingArgument",option);
1021 list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i]);
1023 ThrowAnimateException(OptionError,"UnrecognizedListType",argv[i]);
1024 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
1027 return(status != 0 ? MagickFalse : MagickTrue);
1029 if (LocaleCompare("log",option+1) == 0)
1034 if ((i == (ssize_t) argc) ||
1035 (strchr(argv[i],'%') == (char *) NULL))
1036 ThrowAnimateException(OptionError,"MissingArgument",option);
1039 if (LocaleCompare("loop",option+1) == 0)
1044 if (i == (ssize_t) (argc-1))
1045 ThrowAnimateException(OptionError,"MissingArgument",option);
1046 if (IsGeometry(argv[i]) == MagickFalse)
1047 ThrowAnimateInvalidArgumentException(option,argv[i]);
1050 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1054 if (LocaleCompare("map",option+1) == 0)
1056 resource_info.map_type=(char *) NULL;
1059 (void) CopyMagickString(argv[i]+1,"san",MaxTextExtent);
1061 if (i == (ssize_t) argc)
1062 ThrowAnimateException(OptionError,"MissingArgument",option);
1063 resource_info.map_type=argv[i];
1066 if (LocaleCompare("matte",option+1) == 0)
1068 if (LocaleCompare("mattecolor",option+1) == 0)
1073 if (i == (ssize_t) argc)
1074 ThrowAnimateException(OptionError,"MissingArgument",option);
1075 resource_info.matte_color=argv[i];
1078 if (LocaleCompare("monitor",option+1) == 0)
1080 if (LocaleCompare("monochrome",option+1) == 0)
1084 quantize_info->number_colors=2;
1085 quantize_info->colorspace=GRAYColorspace;
1088 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1092 if (LocaleCompare("name",option+1) == 0)
1094 resource_info.name=(char *) NULL;
1098 if (i == (ssize_t) argc)
1099 ThrowAnimateException(OptionError,"MissingArgument",option);
1100 resource_info.name=ConstantString(argv[i]);
1103 if (LocaleCompare("noop",option+1) == 0)
1105 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1109 if (LocaleCompare("pause",option+1) == 0)
1111 resource_info.pause=0;
1115 if (i == (ssize_t) argc)
1116 ThrowAnimateException(OptionError,"MissingArgument",option);
1117 if (IsGeometry(argv[i]) == MagickFalse)
1118 ThrowAnimateInvalidArgumentException(option,argv[i]);
1119 resource_info.pause=(unsigned int) StringToUnsignedLong(argv[i]);
1122 if (LocaleCompare("page",option+1) == 0)
1127 if (i == (ssize_t) argc)
1128 ThrowAnimateException(OptionError,"MissingArgument",option);
1131 if (LocaleCompare("profile",option+1) == 0)
1134 if (i == (ssize_t) argc)
1135 ThrowAnimateException(OptionError,"MissingArgument",option);
1138 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1142 if (LocaleCompare("quantize",option+1) == 0)
1150 if (i == (ssize_t) (argc-1))
1151 ThrowAnimateException(OptionError,"MissingArgument",option);
1152 colorspace=ParseMagickOption(MagickColorspaceOptions,
1153 MagickFalse,argv[i]);
1155 ThrowAnimateException(OptionError,"UnrecognizedColorspace",
1159 if (LocaleCompare("quiet",option+1) == 0)
1161 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1165 if (LocaleCompare("regard-warnings",option+1) == 0)
1167 if (LocaleCompare("remote",option+1) == 0)
1170 if (i == (ssize_t) argc)
1171 ThrowAnimateException(OptionError,"MissingArgument",option);
1172 if (XRemoteCommand(display,resource_info.window_id,argv[i]) != 0)
1173 return(MagickFalse);
1177 if (LocaleCompare("repage",option+1) == 0)
1182 if (i == (ssize_t) argc)
1183 ThrowAnimateException(OptionError,"MissingArgument",option);
1184 if (IsGeometry(argv[i]) == MagickFalse)
1185 ThrowAnimateInvalidArgumentException(option,argv[i]);
1188 if (LocaleCompare("resample",option+1) == 0)
1193 if (i == (ssize_t) (argc-1))
1194 ThrowAnimateException(OptionError,"MissingArgument",option);
1195 if (IsGeometry(argv[i]) == MagickFalse)
1196 ThrowAnimateInvalidArgumentException(option,argv[i]);
1199 if (LocaleCompare("resize",option+1) == 0)
1204 if (i == (ssize_t) argc)
1205 ThrowAnimateException(OptionError,"MissingArgument",option);
1206 if (IsGeometry(argv[i]) == MagickFalse)
1207 ThrowAnimateInvalidArgumentException(option,argv[i]);
1210 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
1212 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
1215 if (LocaleCompare("rotate",option+1) == 0)
1218 if (i == (ssize_t) argc)
1219 ThrowAnimateException(OptionError,"MissingArgument",option);
1220 if (IsGeometry(argv[i]) == MagickFalse)
1221 ThrowAnimateInvalidArgumentException(option,argv[i]);
1224 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1228 if (LocaleCompare("sampling-factor",option+1) == 0)
1233 if (i == (ssize_t) argc)
1234 ThrowAnimateException(OptionError,"MissingArgument",option);
1235 if (IsGeometry(argv[i]) == MagickFalse)
1236 ThrowAnimateInvalidArgumentException(option,argv[i]);
1239 if (LocaleCompare("seed",option+1) == 0)
1244 if (i == (ssize_t) (argc-1))
1245 ThrowAnimateException(OptionError,"MissingArgument",option);
1246 if (IsGeometry(argv[i]) == MagickFalse)
1247 ThrowAnimateInvalidArgumentException(option,argv[i]);
1250 if (LocaleCompare("scenes",option+1) == 0) /* deprecated */
1255 if (i == (ssize_t) argc)
1256 ThrowAnimateException(OptionError,"MissingArgument",option);
1257 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
1258 ThrowAnimateInvalidArgumentException(option,argv[i]);
1261 if (LocaleCompare("set",option+1) == 0)
1264 if (i == (ssize_t) argc)
1265 ThrowAnimateException(OptionError,"MissingArgument",option);
1269 if (i == (ssize_t) argc)
1270 ThrowAnimateException(OptionError,"MissingArgument",option);
1273 if (LocaleCompare("shared-memory",option+1) == 0)
1275 resource_info.use_shared_memory=(*option == '-') ? MagickTrue :
1279 if (LocaleCompare("size",option+1) == 0)
1284 if (i == (ssize_t) argc)
1285 ThrowAnimateException(OptionError,"MissingArgument",option);
1286 if (IsGeometry(argv[i]) == MagickFalse)
1287 ThrowAnimateInvalidArgumentException(option,argv[i]);
1290 if (LocaleCompare("strip",option+1) == 0)
1292 if (LocaleCompare("support",option+1) == 0)
1294 i++; /* deprecated */
1297 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1301 if (LocaleCompare("text-font",option+1) == 0)
1303 resource_info.text_font=(char *) NULL;
1307 if (i == (ssize_t) argc)
1308 ThrowAnimateException(OptionError,"MissingArgument",option);
1309 resource_info.text_font=XGetResourceClass(resource_database,
1310 GetClientName(),"font",argv[i]);
1313 if (LocaleCompare("thumbnail",option+1) == 0)
1318 if (i == (ssize_t) argc)
1319 ThrowAnimateException(OptionError,"MissingArgument",option);
1320 if (IsGeometry(argv[i]) == MagickFalse)
1321 ThrowAnimateInvalidArgumentException(option,argv[i]);
1324 if (LocaleCompare("title",option+1) == 0)
1326 resource_info.title=(char *) NULL;
1330 if (i == (ssize_t) argc)
1331 ThrowAnimateException(OptionError,"MissingArgument",option);
1332 resource_info.title=argv[i];
1335 if (LocaleCompare("transparent-color",option+1) == 0)
1340 if (i == (ssize_t) (argc-1))
1341 ThrowAnimateException(OptionError,"MissingArgument",option);
1344 if (LocaleCompare("treedepth",option+1) == 0)
1346 quantize_info->tree_depth=0;
1350 if (i == (ssize_t) argc)
1351 ThrowAnimateException(OptionError,"MissingArgument",option);
1352 if (IsGeometry(argv[i]) == MagickFalse)
1353 ThrowAnimateInvalidArgumentException(option,argv[i]);
1354 quantize_info->tree_depth=StringToUnsignedLong(argv[i]);
1357 if (LocaleCompare("trim",option+1) == 0)
1359 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1363 if (LocaleCompare("verbose",option+1) == 0)
1365 if ((LocaleCompare("version",option+1) == 0) ||
1366 (LocaleCompare("-version",option+1) == 0))
1368 (void) fprintf(stdout,"Version: %s\n",
1369 GetMagickVersion((size_t *) NULL));
1370 (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
1371 (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
1374 if (LocaleCompare("virtual-pixel",option+1) == 0)
1382 if (i == (ssize_t) argc)
1383 ThrowAnimateException(OptionError,"MissingArgument",option);
1384 method=ParseMagickOption(MagickVirtualPixelOptions,MagickFalse,
1387 ThrowAnimateException(OptionError,
1388 "UnrecognizedVirtualPixelMethod",argv[i]);
1391 if (LocaleCompare("visual",option+1) == 0)
1393 resource_info.visual_type=(char *) NULL;
1397 if (i == (ssize_t) argc)
1398 ThrowAnimateException(OptionError,"MissingArgument",option);
1399 resource_info.visual_type=argv[i];
1402 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1406 if (LocaleCompare("window",option+1) == 0)
1408 resource_info.window_id=(char *) NULL;
1412 if (i == (ssize_t) argc)
1413 ThrowAnimateException(OptionError,"MissingArgument",option);
1414 resource_info.window_id=argv[i];
1417 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1422 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1424 fire=ParseMagickOption(MagickImageListOptions,MagickFalse,option+1) < 0 ?
1425 MagickFalse : MagickTrue;
1426 if (fire != MagickFalse)
1427 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
1431 ThrowAnimateException(OptionError,"UnbalancedParenthesis",argv[i]);
1432 if (image == (Image *) NULL)
1433 ThrowAnimateException(OptionError,"MissingAnImageFilename",argv[argc-1])
1434 FinalizeImageSettings(image_info,image,MagickTrue);
1435 if (image == (Image *) NULL)
1436 ThrowAnimateException(OptionError,"MissingAnImageFilename",argv[argc-1])
1437 if (resource_info.window_id != (char *) NULL)
1439 XAnimateBackgroundImage(display,&resource_info,image);
1448 Animate image to X server.
1450 animate_image=XAnimateImages(display,&resource_info,argv,argc,image);
1451 status&=animate_image != (Image *) NULL;
1452 while (animate_image != (Image *) NULL)
1454 image=animate_image;
1455 animate_image=XAnimateImages(display,&resource_info,argv,argc,image);
1456 if (animate_image != image)
1457 image=DestroyImageList(image);
1461 return(status != 0 ? MagickTrue : MagickFalse);
1465 (void) ThrowMagickException(exception,GetMagickModule(),MissingDelegateError,
1466 "DelegateLibrarySupportNotBuiltIn","`%s' (X11)",image_info->filename);
1467 return(AnimateUsage());