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];
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) fprintf(stdout,"Version: %s\n",
316 GetMagickVersion((size_t *) NULL));
317 (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
318 (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
324 display=(Display *) NULL;
328 option=(char *) NULL;
330 respect_parenthesis=MagickFalse;
331 resource_database=(XrmDatabase) NULL;
332 (void) ResetMagickMemory(&resource_info,0,sizeof(XResourceInfo));
333 server_name=(char *) NULL;
336 Check for server name specified on the command line.
338 ReadCommandlLine(argc,&argv);
339 status=ExpandFilenames(&argc,&argv);
340 if (status == MagickFalse)
341 ThrowAnimateException(ResourceLimitError,"MemoryAllocationFailed",
342 image_info->filename);
343 for (i=1; i < (ssize_t) argc; i++)
346 Check command line for server name.
349 if (LocaleCompare("display",option+1) == 0)
352 User specified server name.
355 if (i == (ssize_t) argc)
356 ThrowAnimateException(OptionError,"MissingArgument",option);
359 if ((LocaleCompare("help",option+1) == 0) ||
360 (LocaleCompare("-help",option+1) == 0))
361 return(AnimateUsage());
364 Get user defaults from X resource database.
366 display=XOpenDisplay(server_name);
367 if (display == (Display *) NULL)
368 ThrowAnimateException(XServerError,"UnableToOpenXServer",
369 XDisplayName(server_name));
370 (void) XSetErrorHandler(XError);
371 resource_database=XGetResourceDatabase(display,GetClientName());
372 XGetResourceInfo(image_info,resource_database,GetClientName(),
374 quantize_info=resource_info.quantize_info;
375 image_info->density=XGetResourceInstance(resource_database,GetClientName(),
376 "density",(char *) NULL);
377 if (image_info->density == (char *) NULL)
378 image_info->density=XGetScreenDensity(display);
379 resource_value=XGetResourceInstance(resource_database,GetClientName(),
381 image_info->interlace=(InterlaceType)
382 ParseCommandOption(MagickInterlaceOptions,MagickFalse,resource_value);
383 resource_value=XGetResourceInstance(resource_database,GetClientName(),
385 image_info->verbose=IsMagickTrue(resource_value);
386 resource_value=XGetResourceInstance(resource_database,GetClientName(),
388 quantize_info->dither=IsMagickTrue(resource_value);
392 for (i=1; i <= (ssize_t) argc; i++)
394 if (i < (ssize_t) argc)
397 if (image != (Image *) NULL)
400 if (isatty(STDIN_FILENO) != MagickFalse)
416 if (LocaleCompare(option,"(") == 0)
418 FireImageStack(MagickFalse,MagickTrue,pend);
419 if (k == MaxImageStackDepth)
420 ThrowAnimateException(OptionError,"ParenthesisNestedTooDeeply",
425 if (LocaleCompare(option,")") == 0)
427 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
429 ThrowAnimateException(OptionError,"UnableToParseExpression",option);
433 if (IsCommandOption(option) == MagickFalse)
444 FireImageStack(MagickFalse,MagickFalse,pend);
446 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
451 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
452 if (image_info->ping != MagickFalse)
453 images=PingImages(image_info,exception);
455 images=ReadImages(image_info,exception);
456 status&=(images != (Image *) NULL) &&
457 (exception->severity < ErrorException);
458 if (images == (Image *) NULL)
460 AppendImageStack(images);
463 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
468 if (LocaleCompare("alpha",option+1) == 0)
476 if (i == (ssize_t) argc)
477 ThrowAnimateException(OptionError,"MissingArgument",option);
478 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
480 ThrowAnimateException(OptionError,"UnrecognizedAlphaChannelType",
484 if (LocaleCompare("authenticate",option+1) == 0)
489 if (i == (ssize_t) argc)
490 ThrowAnimateException(OptionError,"MissingArgument",option);
493 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
497 if (LocaleCompare("backdrop",option+1) == 0)
499 resource_info.backdrop=(*option == '-') ? MagickTrue : MagickFalse;
502 if (LocaleCompare("background",option+1) == 0)
507 if (i == (ssize_t) argc)
508 ThrowAnimateException(OptionError,"MissingArgument",option);
509 resource_info.background_color=argv[i];
512 if (LocaleCompare("bordercolor",option+1) == 0)
517 if (i == (ssize_t) argc)
518 ThrowAnimateException(OptionError,"MissingArgument",option);
519 resource_info.border_color=argv[i];
522 if (LocaleCompare("borderwidth",option+1) == 0)
524 resource_info.border_width=0;
528 if ((i == (ssize_t) argc) || (IsGeometry(argv[i]) == MagickFalse))
529 ThrowAnimateException(OptionError,"MissingArgument",option);
530 resource_info.border_width=(unsigned int)
531 StringToUnsignedLong(argv[i]);
534 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
538 if (LocaleCompare("cache",option+1) == 0)
543 if (i == (ssize_t) argc)
544 ThrowAnimateException(OptionError,"MissingArgument",option);
545 if (IsGeometry(argv[i]) == MagickFalse)
546 ThrowAnimateInvalidArgumentException(option,argv[i]);
549 if (LocaleCompare("channel",option+1) == 0)
557 if (i == (ssize_t) (argc-1))
558 ThrowAnimateException(OptionError,"MissingArgument",option);
559 channel=ParseChannelOption(argv[i]);
561 ThrowAnimateException(OptionError,"UnrecognizedChannelType",
565 if (LocaleCompare("clone",option+1) == 0)
572 clone_images=image_stack[k-1].image;
573 if (clone_images == (Image *) NULL)
574 ThrowAnimateException(ImageError,"ImageSequenceRequired",option);
575 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
577 clone_images=CloneImages(clone_images,"-1",exception);
581 if (i == (ssize_t) (argc-1))
582 ThrowAnimateException(OptionError,"MissingArgument",option);
583 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
584 ThrowAnimateInvalidArgumentException(option,argv[i]);
585 clone_images=CloneImages(clone_images,argv[i],exception);
587 if (clone_images == (Image *) NULL)
588 ThrowAnimateException(OptionError,"NoSuchImage",option);
589 AppendImageStack(clone_images);
592 if (LocaleCompare("coalesce",option+1) == 0)
594 if (LocaleCompare("colormap",option+1) == 0)
596 resource_info.colormap=PrivateColormap;
600 if (i == (ssize_t) argc)
601 ThrowAnimateException(OptionError,"MissingArgument",option);
602 resource_info.colormap=UndefinedColormap;
603 if (LocaleCompare("private",argv[i]) == 0)
604 resource_info.colormap=PrivateColormap;
605 if (LocaleCompare("shared",argv[i]) == 0)
606 resource_info.colormap=SharedColormap;
607 if (resource_info.colormap == UndefinedColormap)
608 ThrowAnimateException(OptionError,"UnrecognizedColormapType",
612 if (LocaleCompare("colors",option+1) == 0)
614 quantize_info->number_colors=0;
618 if (i == (ssize_t) argc)
619 ThrowAnimateException(OptionError,"MissingArgument",option);
620 if (IsGeometry(argv[i]) == MagickFalse)
621 ThrowAnimateInvalidArgumentException(option,argv[i]);
622 quantize_info->number_colors=StringToUnsignedLong(argv[i]);
625 if (LocaleCompare("colorspace",option+1) == 0)
633 if (i == (ssize_t) argc)
634 ThrowAnimateException(OptionError,"MissingArgument",option);
635 colorspace=ParseCommandOption(MagickColorspaceOptions,
636 MagickFalse,argv[i]);
638 ThrowAnimateException(OptionError,"UnrecognizedColorspace",
642 if (LocaleCompare("concurrent",option+1) == 0)
644 if (LocaleCompare("crop",option+1) == 0)
649 if (i == (ssize_t) argc)
650 ThrowAnimateException(OptionError,"MissingArgument",option);
651 if (IsGeometry(argv[i]) == MagickFalse)
652 ThrowAnimateInvalidArgumentException(option,argv[i]);
655 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
659 if (LocaleCompare("debug",option+1) == 0)
667 if (i == (ssize_t) argc)
668 ThrowAnimateException(OptionError,"MissingArgument",option);
669 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
671 ThrowAnimateException(OptionError,"UnrecognizedEventType",
673 (void) SetLogEventMask(argv[i]);
676 if (LocaleCompare("decipher",option+1) == 0)
681 if (i == (ssize_t) (argc-1))
682 ThrowAnimateException(OptionError,"MissingArgument",option);
685 if (LocaleCompare("define",option+1) == 0)
688 if (i == (ssize_t) argc)
689 ThrowAnimateException(OptionError,"MissingArgument",option);
695 define=GetImageOption(image_info,argv[i]);
696 if (define == (const char *) NULL)
697 ThrowAnimateException(OptionError,"NoSuchOption",argv[i]);
702 if (LocaleCompare("delay",option+1) == 0)
707 if (i == (ssize_t) argc)
708 ThrowAnimateException(OptionError,"MissingArgument",option);
709 if (IsGeometry(argv[i]) == MagickFalse)
710 ThrowAnimateInvalidArgumentException(option,argv[i]);
713 if (LocaleCompare("density",option+1) == 0)
718 if (i == (ssize_t) argc)
719 ThrowAnimateException(OptionError,"MissingArgument",option);
720 if (IsGeometry(argv[i]) == MagickFalse)
721 ThrowAnimateInvalidArgumentException(option,argv[i]);
724 if (LocaleCompare("depth",option+1) == 0)
729 if (i == (ssize_t) argc)
730 ThrowAnimateException(OptionError,"MissingArgument",option);
731 if (IsGeometry(argv[i]) == MagickFalse)
732 ThrowAnimateInvalidArgumentException(option,argv[i]);
735 if (LocaleCompare("display",option+1) == 0)
740 if (i == (ssize_t) argc)
741 ThrowAnimateException(OptionError,"MissingArgument",option);
744 if (LocaleCompare("dispose",option+1) == 0)
752 if (i == (ssize_t) argc)
753 ThrowAnimateException(OptionError,"MissingArgument",option);
754 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
756 ThrowAnimateException(OptionError,"UnrecognizedDisposeMethod",
760 if (LocaleCompare("dither",option+1) == 0)
765 quantize_info->dither=MagickFalse;
769 if (i == (ssize_t) argc)
770 ThrowAnimateException(OptionError,"MissingArgument",option);
771 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
773 ThrowAnimateException(OptionError,"UnrecognizedDitherMethod",
775 quantize_info->dither=MagickTrue;
776 quantize_info->dither_method=(DitherMethod) method;
779 if (LocaleCompare("duration",option+1) == 0)
784 if (i == (ssize_t) (argc-1))
785 ThrowAnimateException(OptionError,"MissingArgument",option);
786 if (IsGeometry(argv[i]) == MagickFalse)
787 ThrowAnimateInvalidArgumentException(option,argv[i]);
790 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
794 if (LocaleCompare("extract",option+1) == 0)
799 if (i == (ssize_t) argc)
800 ThrowAnimateException(OptionError,"MissingArgument",option);
801 if (IsGeometry(argv[i]) == MagickFalse)
802 ThrowAnimateInvalidArgumentException(option,argv[i]);
805 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
809 if (LocaleCompare("filter",option+1) == 0)
817 if (i == (ssize_t) (argc-1))
818 ThrowAnimateException(OptionError,"MissingArgument",option);
819 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
821 ThrowAnimateException(OptionError,"UnrecognizedImageFilter",
825 if (LocaleCompare("flatten",option+1) == 0)
827 if (LocaleCompare("font",option+1) == 0)
832 if (i == (ssize_t) argc)
833 ThrowAnimateException(OptionError,"MissingArgument",option);
834 resource_info.font=XGetResourceClass(resource_database,
835 GetClientName(),"font",argv[i]);
838 if (LocaleCompare("foreground",option+1) == 0)
843 if (i == (ssize_t) argc)
844 ThrowAnimateException(OptionError,"MissingArgument",option);
845 resource_info.foreground_color=argv[i];
848 if (LocaleCompare("format",option+1) == 0)
853 if (i == (ssize_t) (argc-1))
854 ThrowAnimateException(OptionError,"MissingArgument",option);
857 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
861 if (LocaleCompare("gamma",option+1) == 0)
864 if (i == (ssize_t) argc)
865 ThrowAnimateException(OptionError,"MissingArgument",option);
866 if (IsGeometry(argv[i]) == MagickFalse)
867 ThrowAnimateInvalidArgumentException(option,argv[i]);
870 if (LocaleCompare("geometry",option+1) == 0)
872 resource_info.image_geometry=(char *) NULL;
876 if (i == (ssize_t) argc)
877 ThrowAnimateException(OptionError,"MissingArgument",option);
878 if (IsGeometry(argv[i]) == MagickFalse)
879 ThrowAnimateInvalidArgumentException(option,argv[i]);
880 resource_info.image_geometry=ConstantString(argv[i]);
883 if (LocaleCompare("gravity",option+1) == 0)
891 if (i == (ssize_t) (argc-1))
892 ThrowAnimateException(OptionError,"MissingArgument",option);
893 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
896 ThrowAnimateException(OptionError,"UnrecognizedGravityType",
900 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
904 if ((LocaleCompare("help",option+1) == 0) ||
905 (LocaleCompare("-help",option+1) == 0))
907 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
911 if (LocaleCompare("iconGeometry",option+1) == 0)
913 resource_info.icon_geometry=(char *) NULL;
917 if (i == (ssize_t) argc)
918 ThrowAnimateException(OptionError,"MissingArgument",option);
919 if (IsGeometry(argv[i]) == MagickFalse)
920 ThrowAnimateInvalidArgumentException(option,argv[i]);
921 resource_info.icon_geometry=argv[i];
924 if (LocaleCompare("iconic",option+1) == 0)
926 resource_info.iconic=(*option == '-') ? MagickTrue : MagickFalse;
929 if (LocaleCompare("identify",option+1) == 0)
931 if (LocaleCompare("immutable",option+1) == 0)
933 resource_info.immutable=(*option == '-') ? MagickTrue : MagickFalse;
936 if (LocaleCompare("interlace",option+1) == 0)
944 if (i == (ssize_t) argc)
945 ThrowAnimateException(OptionError,"MissingArgument",option);
946 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
949 ThrowAnimateException(OptionError,"UnrecognizedInterlaceType",
953 if (LocaleCompare("interpolate",option+1) == 0)
961 if (i == (ssize_t) argc)
962 ThrowAnimateException(OptionError,"MissingArgument",option);
963 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
966 ThrowAnimateException(OptionError,"UnrecognizedInterpolateMethod",
970 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
974 if (LocaleCompare("label",option+1) == 0)
979 if (i == (ssize_t) argc)
980 ThrowAnimateException(OptionError,"MissingArgument",option);
983 if (LocaleCompare("limit",option+1) == 0)
997 if (i == (ssize_t) argc)
998 ThrowAnimateException(OptionError,"MissingArgument",option);
999 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
1002 ThrowAnimateException(OptionError,"UnrecognizedResourceType",
1005 if (i == (ssize_t) argc)
1006 ThrowAnimateException(OptionError,"MissingArgument",option);
1007 value=StringToDouble(argv[i],&p);
1009 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
1010 ThrowAnimateInvalidArgumentException(option,argv[i]);
1013 if (LocaleCompare("list",option+1) == 0)
1021 if (i == (ssize_t) argc)
1022 ThrowAnimateException(OptionError,"MissingArgument",option);
1023 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
1025 ThrowAnimateException(OptionError,"UnrecognizedListType",argv[i]);
1026 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
1029 return(status != 0 ? MagickFalse : MagickTrue);
1031 if (LocaleCompare("log",option+1) == 0)
1036 if ((i == (ssize_t) argc) ||
1037 (strchr(argv[i],'%') == (char *) NULL))
1038 ThrowAnimateException(OptionError,"MissingArgument",option);
1041 if (LocaleCompare("loop",option+1) == 0)
1046 if (i == (ssize_t) (argc-1))
1047 ThrowAnimateException(OptionError,"MissingArgument",option);
1048 if (IsGeometry(argv[i]) == MagickFalse)
1049 ThrowAnimateInvalidArgumentException(option,argv[i]);
1052 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1056 if (LocaleCompare("map",option+1) == 0)
1058 resource_info.map_type=(char *) NULL;
1061 (void) CopyMagickString(argv[i]+1,"san",MaxTextExtent);
1063 if (i == (ssize_t) argc)
1064 ThrowAnimateException(OptionError,"MissingArgument",option);
1065 resource_info.map_type=argv[i];
1068 if (LocaleCompare("matte",option+1) == 0)
1070 if (LocaleCompare("mattecolor",option+1) == 0)
1075 if (i == (ssize_t) argc)
1076 ThrowAnimateException(OptionError,"MissingArgument",option);
1077 resource_info.matte_color=argv[i];
1080 if (LocaleCompare("monitor",option+1) == 0)
1082 if (LocaleCompare("monochrome",option+1) == 0)
1086 quantize_info->number_colors=2;
1087 quantize_info->colorspace=GRAYColorspace;
1090 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1094 if (LocaleCompare("name",option+1) == 0)
1096 resource_info.name=(char *) NULL;
1100 if (i == (ssize_t) argc)
1101 ThrowAnimateException(OptionError,"MissingArgument",option);
1102 resource_info.name=ConstantString(argv[i]);
1105 if (LocaleCompare("noop",option+1) == 0)
1107 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1111 if (LocaleCompare("pause",option+1) == 0)
1113 resource_info.pause=0;
1117 if (i == (ssize_t) argc)
1118 ThrowAnimateException(OptionError,"MissingArgument",option);
1119 if (IsGeometry(argv[i]) == MagickFalse)
1120 ThrowAnimateInvalidArgumentException(option,argv[i]);
1121 resource_info.pause=(unsigned int) StringToUnsignedLong(argv[i]);
1124 if (LocaleCompare("page",option+1) == 0)
1129 if (i == (ssize_t) argc)
1130 ThrowAnimateException(OptionError,"MissingArgument",option);
1133 if (LocaleCompare("profile",option+1) == 0)
1136 if (i == (ssize_t) argc)
1137 ThrowAnimateException(OptionError,"MissingArgument",option);
1140 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1144 if (LocaleCompare("quantize",option+1) == 0)
1152 if (i == (ssize_t) (argc-1))
1153 ThrowAnimateException(OptionError,"MissingArgument",option);
1154 colorspace=ParseCommandOption(MagickColorspaceOptions,
1155 MagickFalse,argv[i]);
1157 ThrowAnimateException(OptionError,"UnrecognizedColorspace",
1161 if (LocaleCompare("quiet",option+1) == 0)
1163 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1167 if (LocaleCompare("regard-warnings",option+1) == 0)
1169 if (LocaleCompare("remote",option+1) == 0)
1172 if (i == (ssize_t) argc)
1173 ThrowAnimateException(OptionError,"MissingArgument",option);
1174 if (XRemoteCommand(display,resource_info.window_id,argv[i]) != 0)
1175 return(MagickFalse);
1179 if (LocaleCompare("repage",option+1) == 0)
1184 if (i == (ssize_t) argc)
1185 ThrowAnimateException(OptionError,"MissingArgument",option);
1186 if (IsGeometry(argv[i]) == MagickFalse)
1187 ThrowAnimateInvalidArgumentException(option,argv[i]);
1190 if (LocaleCompare("resample",option+1) == 0)
1195 if (i == (ssize_t) (argc-1))
1196 ThrowAnimateException(OptionError,"MissingArgument",option);
1197 if (IsGeometry(argv[i]) == MagickFalse)
1198 ThrowAnimateInvalidArgumentException(option,argv[i]);
1201 if (LocaleCompare("resize",option+1) == 0)
1206 if (i == (ssize_t) argc)
1207 ThrowAnimateException(OptionError,"MissingArgument",option);
1208 if (IsGeometry(argv[i]) == MagickFalse)
1209 ThrowAnimateInvalidArgumentException(option,argv[i]);
1212 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
1214 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
1217 if (LocaleCompare("rotate",option+1) == 0)
1220 if (i == (ssize_t) argc)
1221 ThrowAnimateException(OptionError,"MissingArgument",option);
1222 if (IsGeometry(argv[i]) == MagickFalse)
1223 ThrowAnimateInvalidArgumentException(option,argv[i]);
1226 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1230 if (LocaleCompare("sampling-factor",option+1) == 0)
1235 if (i == (ssize_t) argc)
1236 ThrowAnimateException(OptionError,"MissingArgument",option);
1237 if (IsGeometry(argv[i]) == MagickFalse)
1238 ThrowAnimateInvalidArgumentException(option,argv[i]);
1241 if (LocaleCompare("seed",option+1) == 0)
1246 if (i == (ssize_t) (argc-1))
1247 ThrowAnimateException(OptionError,"MissingArgument",option);
1248 if (IsGeometry(argv[i]) == MagickFalse)
1249 ThrowAnimateInvalidArgumentException(option,argv[i]);
1252 if (LocaleCompare("scenes",option+1) == 0) /* deprecated */
1257 if (i == (ssize_t) argc)
1258 ThrowAnimateException(OptionError,"MissingArgument",option);
1259 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
1260 ThrowAnimateInvalidArgumentException(option,argv[i]);
1263 if (LocaleCompare("set",option+1) == 0)
1266 if (i == (ssize_t) argc)
1267 ThrowAnimateException(OptionError,"MissingArgument",option);
1271 if (i == (ssize_t) argc)
1272 ThrowAnimateException(OptionError,"MissingArgument",option);
1275 if (LocaleCompare("shared-memory",option+1) == 0)
1277 resource_info.use_shared_memory=(*option == '-') ? MagickTrue :
1281 if (LocaleCompare("size",option+1) == 0)
1286 if (i == (ssize_t) argc)
1287 ThrowAnimateException(OptionError,"MissingArgument",option);
1288 if (IsGeometry(argv[i]) == MagickFalse)
1289 ThrowAnimateInvalidArgumentException(option,argv[i]);
1292 if (LocaleCompare("strip",option+1) == 0)
1294 if (LocaleCompare("support",option+1) == 0)
1296 i++; /* deprecated */
1299 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1303 if (LocaleCompare("text-font",option+1) == 0)
1305 resource_info.text_font=(char *) NULL;
1309 if (i == (ssize_t) argc)
1310 ThrowAnimateException(OptionError,"MissingArgument",option);
1311 resource_info.text_font=XGetResourceClass(resource_database,
1312 GetClientName(),"font",argv[i]);
1315 if (LocaleCompare("thumbnail",option+1) == 0)
1320 if (i == (ssize_t) argc)
1321 ThrowAnimateException(OptionError,"MissingArgument",option);
1322 if (IsGeometry(argv[i]) == MagickFalse)
1323 ThrowAnimateInvalidArgumentException(option,argv[i]);
1326 if (LocaleCompare("title",option+1) == 0)
1328 resource_info.title=(char *) NULL;
1332 if (i == (ssize_t) argc)
1333 ThrowAnimateException(OptionError,"MissingArgument",option);
1334 resource_info.title=argv[i];
1337 if (LocaleCompare("transparent-color",option+1) == 0)
1342 if (i == (ssize_t) (argc-1))
1343 ThrowAnimateException(OptionError,"MissingArgument",option);
1346 if (LocaleCompare("treedepth",option+1) == 0)
1348 quantize_info->tree_depth=0;
1352 if (i == (ssize_t) argc)
1353 ThrowAnimateException(OptionError,"MissingArgument",option);
1354 if (IsGeometry(argv[i]) == MagickFalse)
1355 ThrowAnimateInvalidArgumentException(option,argv[i]);
1356 quantize_info->tree_depth=StringToUnsignedLong(argv[i]);
1359 if (LocaleCompare("trim",option+1) == 0)
1361 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1365 if (LocaleCompare("verbose",option+1) == 0)
1367 if ((LocaleCompare("version",option+1) == 0) ||
1368 (LocaleCompare("-version",option+1) == 0))
1370 (void) fprintf(stdout,"Version: %s\n",
1371 GetMagickVersion((size_t *) NULL));
1372 (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
1373 (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
1376 if (LocaleCompare("virtual-pixel",option+1) == 0)
1384 if (i == (ssize_t) argc)
1385 ThrowAnimateException(OptionError,"MissingArgument",option);
1386 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
1389 ThrowAnimateException(OptionError,
1390 "UnrecognizedVirtualPixelMethod",argv[i]);
1393 if (LocaleCompare("visual",option+1) == 0)
1395 resource_info.visual_type=(char *) NULL;
1399 if (i == (ssize_t) argc)
1400 ThrowAnimateException(OptionError,"MissingArgument",option);
1401 resource_info.visual_type=argv[i];
1404 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1408 if (LocaleCompare("window",option+1) == 0)
1410 resource_info.window_id=(char *) NULL;
1414 if (i == (ssize_t) argc)
1415 ThrowAnimateException(OptionError,"MissingArgument",option);
1416 resource_info.window_id=argv[i];
1419 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1424 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1426 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
1427 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
1428 if (fire != MagickFalse)
1429 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
1433 ThrowAnimateException(OptionError,"UnbalancedParenthesis",argv[i]);
1434 if (image == (Image *) NULL)
1435 ThrowAnimateException(OptionError,"MissingAnImageFilename",argv[argc-1])
1436 FinalizeImageSettings(image_info,image,MagickTrue);
1437 if (image == (Image *) NULL)
1438 ThrowAnimateException(OptionError,"MissingAnImageFilename",argv[argc-1])
1439 if (resource_info.window_id != (char *) NULL)
1441 XAnimateBackgroundImage(display,&resource_info,image);
1450 Animate image to X server.
1452 animate_image=XAnimateImages(display,&resource_info,argv,argc,image);
1453 status&=animate_image != (Image *) NULL;
1454 while (animate_image != (Image *) NULL)
1456 image=animate_image;
1457 animate_image=XAnimateImages(display,&resource_info,argv,argc,image);
1458 if (animate_image != image)
1459 image=DestroyImageList(image);
1463 return(status != 0 ? MagickTrue : MagickFalse);
1467 (void) ThrowMagickException(exception,GetMagickModule(),MissingDelegateError,
1468 "DelegateLibrarySupportNotBuiltIn","`%s' (X11)",image_info->filename);
1469 return(AnimateUsage());