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-2013 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/nt-base-private.h"
48 #include "MagickCore/string-private.h"
49 #include "MagickCore/xwindow-private.h"
52 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
56 + A n i m a t e I m a g e C o m m a n d %
60 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
62 % AnimateImageCommand() displays a sequence of images on any workstation
63 % display running an X server. Animate first determines the hardware
64 % capabilities of the workstation. If the number of unique colors in an image
65 % is less than or equal to the number the workstation can support, the image
66 % is displayed in an X window. Otherwise the number of colors in the image is
67 % first reduced to match the color resolution of the workstation before it is
70 % This means that a continuous-tone 24 bits/pixel image can display on a 8
71 % bit pseudo-color device or monochrome device. In most instances the reduced
72 % color image closely resembles the original. Alternatively, a monochrome or
73 % pseudo-color image sequence can display on a continuous-tone 24 bits/pixels
76 % The format of the AnimateImageCommand method is:
78 % MagickBooleanType AnimateImageCommand(ImageInfo *image_info,int argc,
79 % char **argv,char **metadata,ExceptionInfo *exception)
81 % A description of each parameter follows:
83 % o image_info: the image info.
85 % o argc: the number of elements in the argument vector.
87 % o argv: A text array containing the command line arguments.
89 % o metadata: any metadata is returned here.
91 % o exception: return any errors or warnings in this structure.
95 static MagickBooleanType AnimateUsage(void)
103 "Press any button to map or unmap the Command widget",
108 "-debug events display copious debugging information",
109 "-help print program options",
110 "-list type print a list of supported option arguments",
111 "-log format format of debugging information",
112 "-version print version information",
117 "-colors value preferred number of colors in the image",
118 "-crop geometry preferred size and location of the cropped image",
119 "-extract geometry extract area from image",
120 "-monochrome transform image to black and white",
121 "-repage geometry size and location of an image canvas (operator)",
122 "-resample geometry change the resolution of an image",
123 "-resize geometry resize the image",
124 "-rotate degrees apply Paeth rotation to the image",
125 "-strip strip image of all profiles and comments",
126 "-thumbnail geometry create a thumbnail of the image",
127 "-trim trim image edges",
132 "-alpha option on, activate, off, deactivate, set, opaque, copy",
133 " transparent, extract, background, or shape",
134 "-authenticate password",
135 " decipher image with this password",
136 "-backdrop display image centered on a backdrop",
137 "-channel type apply option to select image channels",
138 "-colormap type Shared or Private",
139 "-colorspace type alternate image colorspace",
140 "-decipher filename convert cipher pixels to plain pixels",
141 "-define format:option",
142 " define one or more image format options",
143 "-delay value display the next image after pausing",
144 "-density geometry horizontal and vertical density of the image",
145 "-depth value image depth",
146 "-display server display image to this X server",
147 "-dispose method layer disposal method",
148 "-dither method apply error diffusion to image",
149 "-filter type use this filter when resizing an image",
150 "-format \"string\" output formatted image characteristics",
151 "-gamma value level of gamma correction",
152 "-geometry geometry preferred size and location of the Image window",
153 "-gravity type horizontal and vertical backdrop placement",
154 "-identify identify the format and characteristics of the image",
155 "-immutable displayed image cannot be modified",
156 "-interlace type type of image interlacing scheme",
157 "-interpolate method pixel color interpolation method",
158 "-limit type value pixel cache resource limit",
159 "-loop iterations loop images then exit",
160 "-matte store matte channel if the image has one",
161 "-map type display image using this Standard Colormap",
162 "-monitor monitor progress",
163 "-pause seconds to pause before reanimating",
164 "-page geometry size and location of an image canvas (setting)",
165 "-quantize colorspace reduce colors in this colorspace",
166 "-quiet suppress all warning messages",
167 "-regard-warnings pay attention to warning messages",
168 "-remote command execute a command in an remote display process",
169 "-respect-parentheses settings remain in effect until parenthesis boundary",
170 "-sampling-factor geometry",
171 " horizontal and vertical sampling factor",
172 "-scenes range image scene range",
173 "-seed value seed a new sequence of pseudo-random numbers",
174 "-set attribute value set an image attribute",
175 "-size geometry width and height of image",
176 "-support factor resize support: > 1.0 is blurry, < 1.0 is sharp",
177 "-transparent-color color",
178 " transparent color",
179 "-treedepth value color tree depth",
180 "-verbose print detailed information about the image",
181 "-visual type display image using this visual type",
182 "-virtual-pixel method",
183 " virtual pixel access method",
184 "-window id display image to background of this window",
187 *sequence_operators[]=
189 "-coalesce merge a sequence of images",
190 "-flatten flatten a sequence of images",
194 ListMagickVersion(stdout);
195 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
197 (void) printf("\nImage Settings:\n");
198 for (p=settings; *p != (char *) NULL; p++)
199 (void) printf(" %s\n",*p);
200 (void) printf("\nImage Operators:\n");
201 for (p=operators; *p != (char *) NULL; p++)
202 (void) printf(" %s\n",*p);
203 (void) printf("\nImage Sequence Operators:\n");
204 for (p=sequence_operators; *p != (char *) NULL; p++)
205 (void) printf(" %s\n",*p);
206 (void) printf("\nMiscellaneous Options:\n");
207 for (p=miscellaneous; *p != (char *) NULL; p++)
208 (void) printf(" %s\n",*p);
210 "\nIn addition to those listed above, you can specify these standard X\n");
212 "resources as command line options: -background, -bordercolor,\n");
214 "-borderwidth, -font, -foreground, -iconGeometry, -iconic, -name,\n");
215 (void) printf("-mattecolor, -shared-memory, or -title.\n");
217 "\nBy default, the image format of 'file' is determined by its magic\n");
219 "number. To specify a particular image format, precede the filename\n");
221 "with an image format name and a colon (i.e. ps:image) or specify the\n");
223 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
224 (void) printf("'-' for standard input or output.\n");
225 (void) printf("\nButtons: \n");
226 for (p=buttons; *p != (char *) NULL; p++)
227 (void) printf(" %s\n",*p);
231 WandExport MagickBooleanType AnimateImageCommand(ImageInfo *image_info,
232 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
234 #if defined(MAGICKCORE_X11_DELEGATE)
235 #define DestroyAnimate() \
237 XDestroyResourceInfo(&resource_info); \
238 if (display != (Display *) NULL) \
240 XCloseDisplay(display); \
241 display=(Display *) NULL; \
243 XDestroyResourceInfo(&resource_info); \
244 DestroyImageStack(); \
245 for (i=0; i < (ssize_t) argc; i++) \
246 argv[i]=DestroyString(argv[i]); \
247 argv=(char **) RelinquishMagickMemory(argv); \
249 #define ThrowAnimateException(asperity,tag,option) \
251 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
254 return(MagickFalse); \
256 #define ThrowAnimateInvalidArgumentException(option,argument) \
258 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
259 "InvalidArgument","'%s': %s",option,argument); \
261 return(MagickFalse); \
278 image_stack[MaxImageStackDepth+1];
307 assert(image_info != (ImageInfo *) NULL);
308 assert(image_info->signature == MagickSignature);
309 if (image_info->debug != MagickFalse)
310 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
311 assert(exception != (ExceptionInfo *) NULL);
315 if ((LocaleCompare("version",option+1) == 0) ||
316 (LocaleCompare("-version",option+1) == 0))
318 ListMagickVersion(stdout);
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=IsStringTrue(resource_value);
386 resource_value=XGetResourceInstance(resource_database,GetClientName(),
388 quantize_info->dither_method=IsStringTrue(resource_value) != MagickFalse ?
389 RiemersmaDitherMethod : NoDitherMethod;
393 for (i=1; i <= (ssize_t) argc; i++)
395 if (i < (ssize_t) argc)
398 if (image != (Image *) NULL)
401 if (isatty(STDIN_FILENO) != MagickFalse)
417 if (LocaleCompare(option,"(") == 0)
419 FireImageStack(MagickFalse,MagickTrue,pend);
420 if (k == MaxImageStackDepth)
421 ThrowAnimateException(OptionError,"ParenthesisNestedTooDeeply",
426 if (LocaleCompare(option,")") == 0)
428 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
430 ThrowAnimateException(OptionError,"UnableToParseExpression",option);
434 if (IsCommandOption(option) == MagickFalse)
445 FireImageStack(MagickFalse,MagickFalse,pend);
447 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
452 if (image_info->ping != MagickFalse)
453 images=PingImages(image_info,filename,exception);
455 images=ReadImages(image_info,filename,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(MagickAlphaChannelOptions,MagickFalse,argv[i]);
480 ThrowAnimateException(OptionError,"UnrecognizedAlphaChannelOption",
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,"UnableToCloneImage",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_method=NoDitherMethod;
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_method=(DitherMethod) method;
778 if (LocaleCompare("duration",option+1) == 0)
783 if (i == (ssize_t) (argc-1))
784 ThrowAnimateException(OptionError,"MissingArgument",option);
785 if (IsGeometry(argv[i]) == MagickFalse)
786 ThrowAnimateInvalidArgumentException(option,argv[i]);
789 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
793 if (LocaleCompare("extract",option+1) == 0)
798 if (i == (ssize_t) argc)
799 ThrowAnimateException(OptionError,"MissingArgument",option);
800 if (IsGeometry(argv[i]) == MagickFalse)
801 ThrowAnimateInvalidArgumentException(option,argv[i]);
804 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
808 if (LocaleCompare("filter",option+1) == 0)
816 if (i == (ssize_t) (argc-1))
817 ThrowAnimateException(OptionError,"MissingArgument",option);
818 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
820 ThrowAnimateException(OptionError,"UnrecognizedImageFilter",
824 if (LocaleCompare("flatten",option+1) == 0)
826 if (LocaleCompare("font",option+1) == 0)
831 if (i == (ssize_t) argc)
832 ThrowAnimateException(OptionError,"MissingArgument",option);
833 resource_info.font=XGetResourceClass(resource_database,
834 GetClientName(),"font",argv[i]);
837 if (LocaleCompare("foreground",option+1) == 0)
842 if (i == (ssize_t) argc)
843 ThrowAnimateException(OptionError,"MissingArgument",option);
844 resource_info.foreground_color=argv[i];
847 if (LocaleCompare("format",option+1) == 0)
852 if (i == (ssize_t) (argc-1))
853 ThrowAnimateException(OptionError,"MissingArgument",option);
856 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
860 if (LocaleCompare("gamma",option+1) == 0)
863 if (i == (ssize_t) argc)
864 ThrowAnimateException(OptionError,"MissingArgument",option);
865 if (IsGeometry(argv[i]) == MagickFalse)
866 ThrowAnimateInvalidArgumentException(option,argv[i]);
869 if (LocaleCompare("geometry",option+1) == 0)
871 resource_info.image_geometry=(char *) NULL;
875 if (i == (ssize_t) argc)
876 ThrowAnimateException(OptionError,"MissingArgument",option);
877 if (IsGeometry(argv[i]) == MagickFalse)
878 ThrowAnimateInvalidArgumentException(option,argv[i]);
879 resource_info.image_geometry=ConstantString(argv[i]);
882 if (LocaleCompare("gravity",option+1) == 0)
890 if (i == (ssize_t) (argc-1))
891 ThrowAnimateException(OptionError,"MissingArgument",option);
892 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
895 ThrowAnimateException(OptionError,"UnrecognizedGravityType",
899 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
903 if ((LocaleCompare("help",option+1) == 0) ||
904 (LocaleCompare("-help",option+1) == 0))
906 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
910 if (LocaleCompare("iconGeometry",option+1) == 0)
912 resource_info.icon_geometry=(char *) NULL;
916 if (i == (ssize_t) argc)
917 ThrowAnimateException(OptionError,"MissingArgument",option);
918 if (IsGeometry(argv[i]) == MagickFalse)
919 ThrowAnimateInvalidArgumentException(option,argv[i]);
920 resource_info.icon_geometry=argv[i];
923 if (LocaleCompare("iconic",option+1) == 0)
925 resource_info.iconic=(*option == '-') ? MagickTrue : MagickFalse;
928 if (LocaleCompare("identify",option+1) == 0)
930 if (LocaleCompare("immutable",option+1) == 0)
932 resource_info.immutable=(*option == '-') ? MagickTrue : MagickFalse;
935 if (LocaleCompare("interlace",option+1) == 0)
943 if (i == (ssize_t) argc)
944 ThrowAnimateException(OptionError,"MissingArgument",option);
945 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
948 ThrowAnimateException(OptionError,"UnrecognizedInterlaceType",
952 if (LocaleCompare("interpolate",option+1) == 0)
960 if (i == (ssize_t) argc)
961 ThrowAnimateException(OptionError,"MissingArgument",option);
962 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
965 ThrowAnimateException(OptionError,"UnrecognizedInterpolateMethod",
969 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
973 if (LocaleCompare("label",option+1) == 0)
978 if (i == (ssize_t) argc)
979 ThrowAnimateException(OptionError,"MissingArgument",option);
982 if (LocaleCompare("limit",option+1) == 0)
996 if (i == (ssize_t) argc)
997 ThrowAnimateException(OptionError,"MissingArgument",option);
998 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
1001 ThrowAnimateException(OptionError,"UnrecognizedResourceType",
1004 if (i == (ssize_t) argc)
1005 ThrowAnimateException(OptionError,"MissingArgument",option);
1006 value=StringToDouble(argv[i],&p);
1008 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
1009 ThrowAnimateInvalidArgumentException(option,argv[i]);
1012 if (LocaleCompare("list",option+1) == 0)
1020 if (i == (ssize_t) argc)
1021 ThrowAnimateException(OptionError,"MissingArgument",option);
1022 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
1024 ThrowAnimateException(OptionError,"UnrecognizedListType",argv[i]);
1025 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
1028 return(status != 0 ? MagickFalse : MagickTrue);
1030 if (LocaleCompare("log",option+1) == 0)
1035 if ((i == (ssize_t) argc) ||
1036 (strchr(argv[i],'%') == (char *) NULL))
1037 ThrowAnimateException(OptionError,"MissingArgument",option);
1040 if (LocaleCompare("loop",option+1) == 0)
1045 if (i == (ssize_t) (argc-1))
1046 ThrowAnimateException(OptionError,"MissingArgument",option);
1047 if (IsGeometry(argv[i]) == MagickFalse)
1048 ThrowAnimateInvalidArgumentException(option,argv[i]);
1051 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1055 if (LocaleCompare("map",option+1) == 0)
1057 resource_info.map_type=(char *) NULL;
1060 (void) CopyMagickString(argv[i]+1,"san",MaxTextExtent);
1062 if (i == (ssize_t) argc)
1063 ThrowAnimateException(OptionError,"MissingArgument",option);
1064 resource_info.map_type=argv[i];
1067 if (LocaleCompare("matte",option+1) == 0)
1069 if (LocaleCompare("mattecolor",option+1) == 0)
1074 if (i == (ssize_t) argc)
1075 ThrowAnimateException(OptionError,"MissingArgument",option);
1076 resource_info.matte_color=argv[i];
1079 if (LocaleCompare("monitor",option+1) == 0)
1081 if (LocaleCompare("monochrome",option+1) == 0)
1085 quantize_info->number_colors=2;
1086 quantize_info->colorspace=GRAYColorspace;
1089 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1093 if (LocaleCompare("name",option+1) == 0)
1095 resource_info.name=(char *) NULL;
1099 if (i == (ssize_t) argc)
1100 ThrowAnimateException(OptionError,"MissingArgument",option);
1101 resource_info.name=ConstantString(argv[i]);
1104 if (LocaleCompare("noop",option+1) == 0)
1106 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1110 if (LocaleCompare("pause",option+1) == 0)
1112 resource_info.pause=0;
1116 if (i == (ssize_t) argc)
1117 ThrowAnimateException(OptionError,"MissingArgument",option);
1118 if (IsGeometry(argv[i]) == MagickFalse)
1119 ThrowAnimateInvalidArgumentException(option,argv[i]);
1120 resource_info.pause=(unsigned int) StringToUnsignedLong(argv[i]);
1123 if (LocaleCompare("page",option+1) == 0)
1128 if (i == (ssize_t) argc)
1129 ThrowAnimateException(OptionError,"MissingArgument",option);
1132 if (LocaleCompare("profile",option+1) == 0)
1135 if (i == (ssize_t) argc)
1136 ThrowAnimateException(OptionError,"MissingArgument",option);
1139 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1143 if (LocaleCompare("quantize",option+1) == 0)
1151 if (i == (ssize_t) (argc-1))
1152 ThrowAnimateException(OptionError,"MissingArgument",option);
1153 colorspace=ParseCommandOption(MagickColorspaceOptions,
1154 MagickFalse,argv[i]);
1156 ThrowAnimateException(OptionError,"UnrecognizedColorspace",
1160 if (LocaleCompare("quiet",option+1) == 0)
1162 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1166 if (LocaleCompare("regard-warnings",option+1) == 0)
1168 if (LocaleCompare("remote",option+1) == 0)
1171 if (i == (ssize_t) argc)
1172 ThrowAnimateException(OptionError,"MissingArgument",option);
1173 if (XRemoteCommand(display,resource_info.window_id,argv[i]) != 0)
1174 return(MagickFalse);
1178 if (LocaleCompare("repage",option+1) == 0)
1183 if (i == (ssize_t) argc)
1184 ThrowAnimateException(OptionError,"MissingArgument",option);
1185 if (IsGeometry(argv[i]) == MagickFalse)
1186 ThrowAnimateInvalidArgumentException(option,argv[i]);
1189 if (LocaleCompare("resample",option+1) == 0)
1194 if (i == (ssize_t) (argc-1))
1195 ThrowAnimateException(OptionError,"MissingArgument",option);
1196 if (IsGeometry(argv[i]) == MagickFalse)
1197 ThrowAnimateInvalidArgumentException(option,argv[i]);
1200 if (LocaleCompare("resize",option+1) == 0)
1205 if (i == (ssize_t) argc)
1206 ThrowAnimateException(OptionError,"MissingArgument",option);
1207 if (IsGeometry(argv[i]) == MagickFalse)
1208 ThrowAnimateInvalidArgumentException(option,argv[i]);
1211 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
1213 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
1216 if (LocaleCompare("rotate",option+1) == 0)
1219 if (i == (ssize_t) argc)
1220 ThrowAnimateException(OptionError,"MissingArgument",option);
1221 if (IsGeometry(argv[i]) == MagickFalse)
1222 ThrowAnimateInvalidArgumentException(option,argv[i]);
1225 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1229 if (LocaleCompare("sampling-factor",option+1) == 0)
1234 if (i == (ssize_t) argc)
1235 ThrowAnimateException(OptionError,"MissingArgument",option);
1236 if (IsGeometry(argv[i]) == MagickFalse)
1237 ThrowAnimateInvalidArgumentException(option,argv[i]);
1240 if (LocaleCompare("seed",option+1) == 0)
1245 if (i == (ssize_t) (argc-1))
1246 ThrowAnimateException(OptionError,"MissingArgument",option);
1247 if (IsGeometry(argv[i]) == MagickFalse)
1248 ThrowAnimateInvalidArgumentException(option,argv[i]);
1251 if (LocaleCompare("scenes",option+1) == 0) /* deprecated */
1256 if (i == (ssize_t) argc)
1257 ThrowAnimateException(OptionError,"MissingArgument",option);
1258 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
1259 ThrowAnimateInvalidArgumentException(option,argv[i]);
1262 if (LocaleCompare("set",option+1) == 0)
1265 if (i == (ssize_t) argc)
1266 ThrowAnimateException(OptionError,"MissingArgument",option);
1270 if (i == (ssize_t) argc)
1271 ThrowAnimateException(OptionError,"MissingArgument",option);
1274 if (LocaleCompare("shared-memory",option+1) == 0)
1276 resource_info.use_shared_memory=(*option == '-') ? MagickTrue :
1280 if (LocaleCompare("size",option+1) == 0)
1285 if (i == (ssize_t) argc)
1286 ThrowAnimateException(OptionError,"MissingArgument",option);
1287 if (IsGeometry(argv[i]) == MagickFalse)
1288 ThrowAnimateInvalidArgumentException(option,argv[i]);
1291 if (LocaleCompare("strip",option+1) == 0)
1293 if (LocaleCompare("support",option+1) == 0)
1295 i++; /* deprecated */
1298 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1302 if (LocaleCompare("text-font",option+1) == 0)
1304 resource_info.text_font=(char *) NULL;
1308 if (i == (ssize_t) argc)
1309 ThrowAnimateException(OptionError,"MissingArgument",option);
1310 resource_info.text_font=XGetResourceClass(resource_database,
1311 GetClientName(),"font",argv[i]);
1314 if (LocaleCompare("thumbnail",option+1) == 0)
1319 if (i == (ssize_t) argc)
1320 ThrowAnimateException(OptionError,"MissingArgument",option);
1321 if (IsGeometry(argv[i]) == MagickFalse)
1322 ThrowAnimateInvalidArgumentException(option,argv[i]);
1325 if (LocaleCompare("title",option+1) == 0)
1327 resource_info.title=(char *) NULL;
1331 if (i == (ssize_t) argc)
1332 ThrowAnimateException(OptionError,"MissingArgument",option);
1333 resource_info.title=argv[i];
1336 if (LocaleCompare("transparent-color",option+1) == 0)
1341 if (i == (ssize_t) (argc-1))
1342 ThrowAnimateException(OptionError,"MissingArgument",option);
1345 if (LocaleCompare("treedepth",option+1) == 0)
1347 quantize_info->tree_depth=0;
1351 if (i == (ssize_t) argc)
1352 ThrowAnimateException(OptionError,"MissingArgument",option);
1353 if (IsGeometry(argv[i]) == MagickFalse)
1354 ThrowAnimateInvalidArgumentException(option,argv[i]);
1355 quantize_info->tree_depth=StringToUnsignedLong(argv[i]);
1358 if (LocaleCompare("trim",option+1) == 0)
1360 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1364 if (LocaleCompare("verbose",option+1) == 0)
1366 if ((LocaleCompare("version",option+1) == 0) ||
1367 (LocaleCompare("-version",option+1) == 0))
1369 ListMagickVersion(stdout);
1372 if (LocaleCompare("virtual-pixel",option+1) == 0)
1380 if (i == (ssize_t) argc)
1381 ThrowAnimateException(OptionError,"MissingArgument",option);
1382 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
1385 ThrowAnimateException(OptionError,
1386 "UnrecognizedVirtualPixelMethod",argv[i]);
1389 if (LocaleCompare("visual",option+1) == 0)
1391 resource_info.visual_type=(char *) NULL;
1395 if (i == (ssize_t) argc)
1396 ThrowAnimateException(OptionError,"MissingArgument",option);
1397 resource_info.visual_type=argv[i];
1400 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1404 if (LocaleCompare("window",option+1) == 0)
1406 resource_info.window_id=(char *) NULL;
1410 if (i == (ssize_t) argc)
1411 ThrowAnimateException(OptionError,"MissingArgument",option);
1412 resource_info.window_id=argv[i];
1415 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1420 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1422 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
1423 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
1424 if (fire != MagickFalse)
1425 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
1429 ThrowAnimateException(OptionError,"UnbalancedParenthesis",argv[i]);
1430 if (image == (Image *) NULL)
1431 ThrowAnimateException(OptionError,"MissingAnImageFilename",argv[argc-1])
1432 FinalizeImageSettings(image_info,image,MagickTrue);
1433 if (image == (Image *) NULL)
1434 ThrowAnimateException(OptionError,"MissingAnImageFilename",argv[argc-1])
1435 if (resource_info.window_id != (char *) NULL)
1437 XAnimateBackgroundImage(display,&resource_info,image,exception);
1446 Animate image to X server.
1448 animate_image=XAnimateImages(display,&resource_info,argv,argc,image,
1450 status&=animate_image != (Image *) NULL;
1451 while (animate_image != (Image *) NULL)
1453 image=animate_image;
1454 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());