43#include "MagickWand/studio.h"
44#include "MagickWand/MagickWand.h"
45#include "MagickWand/mogrify-private.h"
46#include "MagickCore/animate-private.h"
47#include "MagickCore/string-private.h"
93static MagickBooleanType AnimateUsage(
void)
97 " Press any button to map or unmap the Command widget",
99 " -debug events display copious debugging information\n"
100 " -help print program options\n"
101 " -list type print a list of supported option arguments\n"
102 " -log format format of debugging information\n"
103 " -version print version information",
105 " -channel mask set the image channel mask\n"
106 " -colors value preferred number of colors in the image\n"
107 " -crop geometry preferred size and location of the cropped image\n"
108 " -extent geometry set the image size\n"
109 " -extract geometry extract area from image\n"
110 " -monochrome transform image to black and white\n"
111 " -resample geometry change the resolution of an image\n"
112 " -resize geometry resize the image\n"
113 " -rotate degrees apply Paeth rotation to the image\n"
114 " -strip strip image of all profiles and comments\n"
115 " -thumbnail geometry create a thumbnail of the image\n"
116 " -trim trim image edges",
118 " -alpha option on, activate, off, deactivate, set, opaque, copy\n"
119 " transparent, extract, background, or shape\n"
120 " -authenticate password\n"
121 " decipher image with this password\n"
122 " -backdrop display image centered on a backdrop\n"
123 " -colormap type Shared or Private\n"
124 " -colorspace type alternate image colorspace\n"
125 " -decipher filename convert cipher pixels to plain pixels\n"
126 " -define format:option\n"
127 " define one or more image format options\n"
128 " -delay value display the next image after pausing\n"
129 " -density geometry horizontal and vertical density of the image\n"
130 " -depth value image depth\n"
131 " -display server display image to this X server\n"
132 " -dispose method layer disposal method\n"
133 " -dither method apply error diffusion to image\n"
134 " -filter type use this filter when resizing an image\n"
135 " -format \"string\" output formatted image characteristics\n"
136 " -gamma value level of gamma correction\n"
137 " -geometry geometry preferred size and location of the Image window\n"
138 " -gravity type horizontal and vertical backdrop placement\n"
139 " -identify identify the format and characteristics of the image\n"
140 " -immutable displayed image cannot be modified\n"
141 " -interlace type type of image interlacing scheme\n"
142 " -interpolate method pixel color interpolation method\n"
143 " -limit type value pixel cache resource limit\n"
144 " -loop iterations loop images then exit\n"
145 " -matte store matte channel if the image has one\n"
146 " -map type display image using this Standard Colormap\n"
147 " -monitor monitor progress\n"
148 " -pause seconds to pause before reanimating\n"
149 " -page geometry size and location of an image canvas (setting)\n"
150 " -quantize colorspace reduce colors in this colorspace\n"
151 " -quiet suppress all warning messages\n"
152 " -regard-warnings pay attention to warning messages\n"
153 " -remote command execute a command in an remote display process\n"
154 " -repage geometry size and location of an image canvas (operator)\n"
155 " -respect-parentheses settings remain in effect until parenthesis boundary\n"
156 " -sampling-factor geometry\n"
157 " horizontal and vertical sampling factor\n"
158 " -scenes range image scene range\n"
159 " -seed value seed a new sequence of pseudo-random numbers\n"
160 " -set attribute value set an image attribute\n"
161 " -size geometry width and height of image\n"
162 " -support factor resize support: > 1.0 is blurry, < 1.0 is sharp\n"
163 " -transparent-color color\n"
164 " transparent color\n"
165 " -treedepth value color tree depth\n"
166 " -verbose print detailed information about the image\n"
167 " -visual type display image using this visual type\n"
168 " -virtual-pixel method\n"
169 " virtual pixel access method\n"
170 " -window id display image to background of this window",
171 sequence_operators[] =
172 " -coalesce merge a sequence of images\n"
173 " -flatten flatten a sequence of images";
175 ListMagickVersion(stdout);
176 (void) printf(
"Usage: %s [options ...] file [ [options ...] file ...]\n",
178 (void) printf(
"\nImage Settings:\n");
179 (void) puts(settings);
180 (void) printf(
"\nImage Operators:\n");
181 (void) puts(operators);
182 (void) printf(
"\nImage Sequence Operators:\n");
183 (void) puts(sequence_operators);
184 (void) printf(
"\nMiscellaneous Options:\n");
185 (void) puts(miscellaneous);
187 "\nIn addition to those listed above, you can specify these standard X\n");
189 "resources as command line options: -background, -bordercolor,\n");
191 "-mattecolor, -borderwidth, -font, -foreground, -iconGeometry,\n");
192 (void) printf(
"-iconic, -name, -shared-memory, or -title.\n");
194 "\nBy default, the image format of 'file' is determined by its magic\n");
196 "number. To specify a particular image format, precede the filename\n");
198 "with an image format name and a colon (i.e. ps:image) or specify the\n");
200 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
201 (void) printf(
"'-' for standard input or output.\n");
202 (void) printf(
"\nButtons: \n");
203 (void) puts(buttons);
207#if defined(MAGICKCORE_X11_DELEGATE)
208WandExport MagickBooleanType AnimateImageCommand(ImageInfo *image_info,
209 int argc,
char **argv,
char **wand_unused(metadata),ExceptionInfo *exception)
211#define DestroyAnimate() \
213 XDestroyResourceInfo(&resource_info); \
214 if (display != (Display *) NULL) \
216 XCloseDisplay(display); \
217 display=(Display *) NULL; \
219 XDestroyResourceInfo(&resource_info); \
220 DestroyImageStack(); \
221 for (i=0; i < (ssize_t) argc; i++) \
222 argv[i]=DestroyString(argv[i]); \
223 argv=(char **) RelinquishMagickMemory(argv); \
225#define ThrowAnimateException(asperity,tag,option) \
227 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
230 return(MagickFalse); \
232#define ThrowAnimateInvalidArgumentException(option,argument) \
234 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
235 "InvalidArgument","'%s': %s",option,argument); \
237 return(MagickFalse); \
254 image_stack[MaxImageStackDepth+1];
283 assert(image_info != (ImageInfo *) NULL);
284 assert(image_info->signature == MagickCoreSignature);
285 assert(exception != (ExceptionInfo *) NULL);
286 wand_unreferenced(metadata);
287 if (IsEventLogging() != MagickFalse)
288 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
292 if ((LocaleCompare(
"version",option+1) == 0) ||
293 (LocaleCompare(
"-version",option+1) == 0))
295 ListMagickVersion(stdout);
301 display=(Display *) NULL;
305 option=(
char *) NULL;
307 respect_parentheses=MagickFalse;
308 resource_database=(XrmDatabase) NULL;
309 (void) memset(&resource_info,0,
sizeof(XResourceInfo));
310 server_name=(
char *) NULL;
315 ReadCommandlLine(argc,&argv);
316 status=ExpandFilenames(&argc,&argv);
317 if (status == MagickFalse)
318 ThrowAnimateException(ResourceLimitError,
"MemoryAllocationFailed",
319 image_info->filename);
320 for (i=1; i < (ssize_t) argc; i++)
326 if (IsCommandOption(option) == MagickFalse)
328 if (LocaleCompare(
"display",option+1) == 0)
334 if (i == (ssize_t) argc)
335 ThrowAnimateException(OptionError,
"MissingArgument",option);
338 if ((LocaleCompare(
"help",option+1) == 0) ||
339 (LocaleCompare(
"-help",option+1) == 0))
342 return(AnimateUsage());
348 display=XOpenDisplay(server_name);
349 if (display == (Display *) NULL)
350 ThrowAnimateException(XServerError,
"UnableToOpenXServer",
351 XDisplayName(server_name));
352 (void) XSetErrorHandler(XError);
353 resource_database=XGetResourceDatabase(display,GetClientName());
354 XGetResourceInfo(image_info,resource_database,GetClientName(),
356 quantize_info=resource_info.quantize_info;
357 image_info->density=XGetResourceInstance(resource_database,GetClientName(),
358 "density",(
char *) NULL);
359 if (image_info->density == (
char *) NULL)
360 image_info->density=XGetScreenDensity(display);
361 resource_value=XGetResourceInstance(resource_database,GetClientName(),
363 image_info->interlace=(InterlaceType)
364 ParseCommandOption(MagickInterlaceOptions,MagickFalse,resource_value);
365 resource_value=XGetResourceInstance(resource_database,GetClientName(),
367 image_info->verbose=IsStringTrue(resource_value);
368 resource_value=XGetResourceInstance(resource_database,GetClientName(),
370 quantize_info->dither_method=IsStringTrue(resource_value) != MagickFalse ?
371 RiemersmaDitherMethod : NoDitherMethod;
375 for (i=1; i <= (ssize_t) argc; i++)
377 if (i < (ssize_t) argc)
380 if (image != (Image *) NULL)
383 if (isatty(STDIN_FILENO) != MagickFalse)
387 if (LocaleCompare(option,
"(") == 0)
389 FireImageStack(MagickFalse,MagickTrue,pend);
390 if (k == MaxImageStackDepth)
391 ThrowAnimateException(OptionError,
"ParenthesisNestedTooDeeply",
396 if (LocaleCompare(option,
")") == 0)
398 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
400 ThrowAnimateException(OptionError,
"UnableToParseExpression",option);
404 if (IsCommandOption(option) == MagickFalse)
415 FireImageStack(MagickFalse,MagickFalse,pend);
417 if ((LocaleCompare(filename,
"--") == 0) && (i < (ssize_t) (argc-1)))
422 if (image_info->ping != MagickFalse)
423 images=PingImages(image_info,filename,exception);
425 images=ReadImages(image_info,filename,exception);
426 status&=(MagickStatusType) (images != (Image *) NULL) &&
427 (exception->severity < ErrorException);
428 if (images == (Image *) NULL)
430 AppendImageStack(images);
433 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
438 if (LocaleCompare(
"alpha",option+1) == 0)
446 if (i == (ssize_t) argc)
447 ThrowAnimateException(OptionError,
"MissingArgument",option);
448 type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,
451 ThrowAnimateException(OptionError,
452 "UnrecognizedAlphaChannelOption",argv[i]);
455 if (LocaleCompare(
"authenticate",option+1) == 0)
460 if (i == (ssize_t) argc)
461 ThrowAnimateException(OptionError,
"MissingArgument",option);
464 ThrowAnimateException(OptionError,
"UnrecognizedOption",option);
468 if (LocaleCompare(
"backdrop",option+1) == 0)
470 resource_info.backdrop=(*option ==
'-') ? MagickTrue : MagickFalse;
473 if (LocaleCompare(
"background",option+1) == 0)
478 if (i == (ssize_t) argc)
479 ThrowAnimateException(OptionError,
"MissingArgument",option);
480 resource_info.background_color=argv[i];
483 if (LocaleCompare(
"bordercolor",option+1) == 0)
488 if (i == (ssize_t) argc)
489 ThrowAnimateException(OptionError,
"MissingArgument",option);
490 resource_info.border_color=argv[i];
493 if (LocaleCompare(
"borderwidth",option+1) == 0)
495 resource_info.border_width=0;
499 if ((i == (ssize_t) argc) || (IsGeometry(argv[i]) == MagickFalse))
500 ThrowAnimateException(OptionError,
"MissingArgument",option);
501 resource_info.border_width=(
unsigned int)
502 StringToUnsignedLong(argv[i]);
505 ThrowAnimateException(OptionError,
"UnrecognizedOption",option);
509 if (LocaleCompare(
"cache",option+1) == 0)
514 if (i == (ssize_t) argc)
515 ThrowAnimateException(OptionError,
"MissingArgument",option);
516 if (IsGeometry(argv[i]) == MagickFalse)
517 ThrowAnimateInvalidArgumentException(option,argv[i]);
520 if (LocaleCompare(
"channel",option+1) == 0)
528 if (i == (ssize_t) argc)
529 ThrowAnimateException(OptionError,
"MissingArgument",option);
530 channel=ParseChannelOption(argv[i]);
532 ThrowAnimateException(OptionError,
"UnrecognizedChannelType",
536 if (LocaleCompare(
"clone",option+1) == 0)
543 clone_images=image_stack[k-1].image;
544 if (clone_images == (Image *) NULL)
545 ThrowAnimateException(ImageError,
"UnableToCloneImage",option);
546 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
548 clone_images=CloneImages(clone_images,
"-1",exception);
552 if (i == (ssize_t) argc)
553 ThrowAnimateException(OptionError,
"MissingArgument",option);
554 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
555 ThrowAnimateInvalidArgumentException(option,argv[i]);
556 clone_images=CloneImages(clone_images,argv[i],exception);
558 if (clone_images == (Image *) NULL)
559 ThrowAnimateException(OptionError,
"NoSuchImage",option);
560 AppendImageStack(clone_images);
563 if (LocaleCompare(
"coalesce",option+1) == 0)
565 if (LocaleCompare(
"colormap",option+1) == 0)
567 resource_info.colormap=PrivateColormap;
571 if (i == (ssize_t) argc)
572 ThrowAnimateException(OptionError,
"MissingArgument",option);
573 resource_info.colormap=UndefinedColormap;
574 if (LocaleCompare(
"private",argv[i]) == 0)
575 resource_info.colormap=PrivateColormap;
576 if (LocaleCompare(
"shared",argv[i]) == 0)
577 resource_info.colormap=SharedColormap;
578 if (resource_info.colormap == UndefinedColormap)
579 ThrowAnimateException(OptionError,
"UnrecognizedColormapType",
583 if (LocaleCompare(
"colors",option+1) == 0)
585 quantize_info->number_colors=0;
589 if (i == (ssize_t) argc)
590 ThrowAnimateException(OptionError,
"MissingArgument",option);
591 if (IsGeometry(argv[i]) == MagickFalse)
592 ThrowAnimateInvalidArgumentException(option,argv[i]);
593 quantize_info->number_colors=StringToUnsignedLong(argv[i]);
596 if (LocaleCompare(
"colorspace",option+1) == 0)
604 if (i == (ssize_t) argc)
605 ThrowAnimateException(OptionError,
"MissingArgument",option);
606 colorspace=ParseCommandOption(MagickColorspaceOptions,
607 MagickFalse,argv[i]);
609 ThrowAnimateException(OptionError,
"UnrecognizedColorspace",
613 if (LocaleCompare(
"concurrent",option+1) == 0)
615 if (LocaleCompare(
"crop",option+1) == 0)
620 if (i == (ssize_t) argc)
621 ThrowAnimateException(OptionError,
"MissingArgument",option);
622 if (IsGeometry(argv[i]) == MagickFalse)
623 ThrowAnimateInvalidArgumentException(option,argv[i]);
626 ThrowAnimateException(OptionError,
"UnrecognizedOption",option);
630 if (LocaleCompare(
"debug",option+1) == 0)
638 if (i == (ssize_t) argc)
639 ThrowAnimateException(OptionError,
"MissingArgument",option);
640 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
642 ThrowAnimateException(OptionError,
"UnrecognizedEventType",
644 (void) SetLogEventMask(argv[i]);
647 if (LocaleCompare(
"decipher",option+1) == 0)
652 if (i == (ssize_t) argc)
653 ThrowAnimateException(OptionError,
"MissingArgument",option);
656 if (LocaleCompare(
"define",option+1) == 0)
659 if (i == (ssize_t) argc)
660 ThrowAnimateException(OptionError,
"MissingArgument",option);
666 define=GetImageOption(image_info,argv[i]);
667 if (define == (
const char *) NULL)
668 ThrowAnimateException(OptionError,
"NoSuchOption",argv[i]);
673 if (LocaleCompare(
"delay",option+1) == 0)
678 if (i == (ssize_t) argc)
679 ThrowAnimateException(OptionError,
"MissingArgument",option);
680 if (IsGeometry(argv[i]) == MagickFalse)
681 ThrowAnimateInvalidArgumentException(option,argv[i]);
684 if (LocaleCompare(
"density",option+1) == 0)
689 if (i == (ssize_t) argc)
690 ThrowAnimateException(OptionError,
"MissingArgument",option);
691 if (IsGeometry(argv[i]) == MagickFalse)
692 ThrowAnimateInvalidArgumentException(option,argv[i]);
695 if (LocaleCompare(
"depth",option+1) == 0)
700 if (i == (ssize_t) argc)
701 ThrowAnimateException(OptionError,
"MissingArgument",option);
702 if (IsGeometry(argv[i]) == MagickFalse)
703 ThrowAnimateInvalidArgumentException(option,argv[i]);
706 if (LocaleCompare(
"display",option+1) == 0)
711 if (i == (ssize_t) argc)
712 ThrowAnimateException(OptionError,
"MissingArgument",option);
715 if (LocaleCompare(
"dispose",option+1) == 0)
723 if (i == (ssize_t) argc)
724 ThrowAnimateException(OptionError,
"MissingArgument",option);
725 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
727 ThrowAnimateException(OptionError,
"UnrecognizedDisposeMethod",
731 if (LocaleCompare(
"dither",option+1) == 0)
736 quantize_info->dither_method=NoDitherMethod;
740 if (i == (ssize_t) argc)
741 ThrowAnimateException(OptionError,
"MissingArgument",option);
742 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
744 ThrowAnimateException(OptionError,
"UnrecognizedDitherMethod",
746 quantize_info->dither_method=(DitherMethod) method;
749 if (LocaleCompare(
"duration",option+1) == 0)
754 if (i == (ssize_t) argc)
755 ThrowAnimateException(OptionError,
"MissingArgument",option);
756 if (IsGeometry(argv[i]) == MagickFalse)
757 ThrowAnimateInvalidArgumentException(option,argv[i]);
760 ThrowAnimateException(OptionError,
"UnrecognizedOption",option);
764 if (LocaleCompare(
"extent",option+1) == 0)
769 if (i == (ssize_t) argc)
770 ThrowAnimateException(OptionError,
"MissingArgument",option);
771 if (IsGeometry(argv[i]) == MagickFalse)
772 ThrowAnimateInvalidArgumentException(option,argv[i]);
775 if (LocaleCompare(
"extract",option+1) == 0)
780 if (i == (ssize_t) argc)
781 ThrowAnimateException(OptionError,
"MissingArgument",option);
782 if (IsGeometry(argv[i]) == MagickFalse)
783 ThrowAnimateInvalidArgumentException(option,argv[i]);
786 ThrowAnimateException(OptionError,
"UnrecognizedOption",option);
790 if (LocaleCompare(
"filter",option+1) == 0)
798 if (i == (ssize_t) argc)
799 ThrowAnimateException(OptionError,
"MissingArgument",option);
800 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
802 ThrowAnimateException(OptionError,
"UnrecognizedImageFilter",
806 if (LocaleCompare(
"flatten",option+1) == 0)
808 if (LocaleCompare(
"font",option+1) == 0)
813 if (i == (ssize_t) argc)
814 ThrowAnimateException(OptionError,
"MissingArgument",option);
815 resource_info.font=XGetResourceClass(resource_database,
816 GetClientName(),
"font",argv[i]);
819 if (LocaleCompare(
"foreground",option+1) == 0)
824 if (i == (ssize_t) argc)
825 ThrowAnimateException(OptionError,
"MissingArgument",option);
826 resource_info.foreground_color=argv[i];
829 if (LocaleCompare(
"format",option+1) == 0)
834 if (i == (ssize_t) argc)
835 ThrowAnimateException(OptionError,
"MissingArgument",option);
838 ThrowAnimateException(OptionError,
"UnrecognizedOption",option);
842 if (LocaleCompare(
"gamma",option+1) == 0)
845 if (i == (ssize_t) argc)
846 ThrowAnimateException(OptionError,
"MissingArgument",option);
847 if (IsGeometry(argv[i]) == MagickFalse)
848 ThrowAnimateInvalidArgumentException(option,argv[i]);
851 if (LocaleCompare(
"geometry",option+1) == 0)
853 resource_info.image_geometry=(
char *) NULL;
857 if (i == (ssize_t) argc)
858 ThrowAnimateException(OptionError,
"MissingArgument",option);
859 if (IsGeometry(argv[i]) == MagickFalse)
860 ThrowAnimateInvalidArgumentException(option,argv[i]);
861 resource_info.image_geometry=ConstantString(argv[i]);
864 if (LocaleCompare(
"gravity",option+1) == 0)
872 if (i == (ssize_t) argc)
873 ThrowAnimateException(OptionError,
"MissingArgument",option);
874 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
877 ThrowAnimateException(OptionError,
"UnrecognizedGravityType",
881 ThrowAnimateException(OptionError,
"UnrecognizedOption",option);
885 if ((LocaleCompare(
"help",option+1) == 0) ||
886 (LocaleCompare(
"-help",option+1) == 0))
888 ThrowAnimateException(OptionError,
"UnrecognizedOption",option);
892 if (LocaleCompare(
"iconGeometry",option+1) == 0)
894 resource_info.icon_geometry=(
char *) NULL;
898 if (i == (ssize_t) argc)
899 ThrowAnimateException(OptionError,
"MissingArgument",option);
900 if (IsGeometry(argv[i]) == MagickFalse)
901 ThrowAnimateInvalidArgumentException(option,argv[i]);
902 resource_info.icon_geometry=argv[i];
905 if (LocaleCompare(
"iconic",option+1) == 0)
907 resource_info.iconic=(*option ==
'-') ? MagickTrue : MagickFalse;
910 if (LocaleCompare(
"identify",option+1) == 0)
912 if (LocaleCompare(
"immutable",option+1) == 0)
914 resource_info.immutable=(*option ==
'-') ? MagickTrue : MagickFalse;
917 if (LocaleCompare(
"interlace",option+1) == 0)
925 if (i == (ssize_t) argc)
926 ThrowAnimateException(OptionError,
"MissingArgument",option);
927 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
930 ThrowAnimateException(OptionError,
"UnrecognizedInterlaceType",
934 if (LocaleCompare(
"interpolate",option+1) == 0)
942 if (i == (ssize_t) argc)
943 ThrowAnimateException(OptionError,
"MissingArgument",option);
944 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
947 ThrowAnimateException(OptionError,
"UnrecognizedInterpolateMethod",
951 ThrowAnimateException(OptionError,
"UnrecognizedOption",option);
955 if (LocaleCompare(
"label",option+1) == 0)
960 if (i == (ssize_t) argc)
961 ThrowAnimateException(OptionError,
"MissingArgument",option);
964 if (LocaleCompare(
"limit",option+1) == 0)
978 if (i == (ssize_t) argc)
979 ThrowAnimateException(OptionError,
"MissingArgument",option);
980 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
983 ThrowAnimateException(OptionError,
"UnrecognizedResourceType",
986 if (i == (ssize_t) argc)
987 ThrowAnimateException(OptionError,
"MissingArgument",option);
988 value=StringToDouble(argv[i],&p);
990 if ((p == argv[i]) && (LocaleCompare(
"unlimited",argv[i]) != 0))
991 ThrowAnimateInvalidArgumentException(option,argv[i]);
994 if (LocaleCompare(
"list",option+1) == 0)
1002 if (i == (ssize_t) argc)
1003 ThrowAnimateException(OptionError,
"MissingArgument",option);
1004 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
1006 ThrowAnimateException(OptionError,
"UnrecognizedListType",argv[i]);
1007 status=MogrifyImageInfo(image_info,(
int) (i-j+1),(
const char **)
1010 return(status == 0 ? MagickFalse : MagickTrue);
1012 if (LocaleCompare(
"log",option+1) == 0)
1017 if ((i == (ssize_t) argc) ||
1018 (strchr(argv[i],
'%') == (
char *) NULL))
1019 ThrowAnimateException(OptionError,
"MissingArgument",option);
1022 if (LocaleCompare(
"loop",option+1) == 0)
1027 if (i == (ssize_t) argc)
1028 ThrowAnimateException(OptionError,
"MissingArgument",option);
1029 if (IsGeometry(argv[i]) == MagickFalse)
1030 ThrowAnimateInvalidArgumentException(option,argv[i]);
1033 ThrowAnimateException(OptionError,
"UnrecognizedOption",option);
1037 if (LocaleCompare(
"map",option+1) == 0)
1039 resource_info.map_type=(
char *) NULL;
1042 (void) CopyMagickString(argv[i]+1,
"san",MagickPathExtent);
1044 if (i == (ssize_t) argc)
1045 ThrowAnimateException(OptionError,
"MissingArgument",option);
1046 resource_info.map_type=argv[i];
1049 if (LocaleCompare(
"matte",option+1) == 0)
1051 if (LocaleCompare(
"mattecolor",option+1) == 0)
1056 if (i == (ssize_t) argc)
1057 ThrowAnimateException(OptionError,
"MissingArgument",option);
1058 resource_info.matte_color=argv[i];
1061 if (LocaleCompare(
"monitor",option+1) == 0)
1063 if (LocaleCompare(
"monochrome",option+1) == 0)
1067 quantize_info->number_colors=2;
1068 quantize_info->colorspace=GRAYColorspace;
1071 ThrowAnimateException(OptionError,
"UnrecognizedOption",option);
1075 if (LocaleCompare(
"name",option+1) == 0)
1077 resource_info.name=(
char *) NULL;
1081 if (i == (ssize_t) argc)
1082 ThrowAnimateException(OptionError,
"MissingArgument",option);
1083 resource_info.name=ConstantString(argv[i]);
1086 if (LocaleCompare(
"noop",option+1) == 0)
1088 ThrowAnimateException(OptionError,
"UnrecognizedOption",option);
1092 if (LocaleCompare(
"pause",option+1) == 0)
1094 resource_info.pause=0;
1098 if (i == (ssize_t) argc)
1099 ThrowAnimateException(OptionError,
"MissingArgument",option);
1100 if (IsGeometry(argv[i]) == MagickFalse)
1101 ThrowAnimateInvalidArgumentException(option,argv[i]);
1102 resource_info.pause=(
unsigned int) StringToUnsignedLong(argv[i]);
1105 if (LocaleCompare(
"page",option+1) == 0)
1110 if (i == (ssize_t) argc)
1111 ThrowAnimateException(OptionError,
"MissingArgument",option);
1114 if (LocaleCompare(
"profile",option+1) == 0)
1117 if (i == (ssize_t) argc)
1118 ThrowAnimateException(OptionError,
"MissingArgument",option);
1121 ThrowAnimateException(OptionError,
"UnrecognizedOption",option);
1125 if (LocaleCompare(
"quantize",option+1) == 0)
1133 if (i == (ssize_t) argc)
1134 ThrowAnimateException(OptionError,
"MissingArgument",option);
1135 colorspace=ParseCommandOption(MagickColorspaceOptions,
1136 MagickFalse,argv[i]);
1138 ThrowAnimateException(OptionError,
"UnrecognizedColorspace",
1142 if (LocaleCompare(
"quiet",option+1) == 0)
1144 ThrowAnimateException(OptionError,
"UnrecognizedOption",option);
1148 if (LocaleCompare(
"regard-warnings",option+1) == 0)
1150 if (LocaleCompare(
"remote",option+1) == 0)
1153 if (i == (ssize_t) argc)
1154 ThrowAnimateException(OptionError,
"MissingArgument",option);
1155 if (XRemoteCommand(display,resource_info.window_id,argv[i]) != 0)
1158 return(MagickFalse);
1163 if (LocaleCompare(
"repage",option+1) == 0)
1168 if (i == (ssize_t) argc)
1169 ThrowAnimateException(OptionError,
"MissingArgument",option);
1170 if (IsGeometry(argv[i]) == MagickFalse)
1171 ThrowAnimateInvalidArgumentException(option,argv[i]);
1174 if (LocaleCompare(
"resample",option+1) == 0)
1179 if (i == (ssize_t) argc)
1180 ThrowAnimateException(OptionError,
"MissingArgument",option);
1181 if (IsGeometry(argv[i]) == MagickFalse)
1182 ThrowAnimateInvalidArgumentException(option,argv[i]);
1185 if (LocaleCompare(
"resize",option+1) == 0)
1190 if (i == (ssize_t) argc)
1191 ThrowAnimateException(OptionError,
"MissingArgument",option);
1192 if (IsGeometry(argv[i]) == MagickFalse)
1193 ThrowAnimateInvalidArgumentException(option,argv[i]);
1196 if (LocaleNCompare(
"respect-parentheses",option+1,17) == 0)
1198 respect_parentheses=(*option ==
'-') ? MagickTrue : MagickFalse;
1201 if (LocaleCompare(
"rotate",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 ThrowAnimateException(OptionError,
"UnrecognizedOption",option);
1214 if (LocaleCompare(
"sampling-factor",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 if (LocaleCompare(
"seed",option+1) == 0)
1230 if (i == (ssize_t) argc)
1231 ThrowAnimateException(OptionError,
"MissingArgument",option);
1232 if (IsGeometry(argv[i]) == MagickFalse)
1233 ThrowAnimateInvalidArgumentException(option,argv[i]);
1236 if (LocaleCompare(
"scenes",option+1) == 0)
1241 if (i == (ssize_t) argc)
1242 ThrowAnimateException(OptionError,
"MissingArgument",option);
1243 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
1244 ThrowAnimateInvalidArgumentException(option,argv[i]);
1247 if (LocaleCompare(
"set",option+1) == 0)
1250 if (i == (ssize_t) argc)
1251 ThrowAnimateException(OptionError,
"MissingArgument",option);
1255 if (i == (ssize_t) argc)
1256 ThrowAnimateException(OptionError,
"MissingArgument",option);
1259 if (LocaleCompare(
"shared-memory",option+1) == 0)
1261 resource_info.use_shared_memory=(*option ==
'-') ? MagickTrue :
1265 if (LocaleCompare(
"size",option+1) == 0)
1270 if (i == (ssize_t) argc)
1271 ThrowAnimateException(OptionError,
"MissingArgument",option);
1272 if (IsGeometry(argv[i]) == MagickFalse)
1273 ThrowAnimateInvalidArgumentException(option,argv[i]);
1276 if (LocaleCompare(
"strip",option+1) == 0)
1278 if (LocaleCompare(
"support",option+1) == 0)
1283 ThrowAnimateException(OptionError,
"UnrecognizedOption",option);
1287 if (LocaleCompare(
"text-font",option+1) == 0)
1289 resource_info.text_font=(
char *) NULL;
1293 if (i == (ssize_t) argc)
1294 ThrowAnimateException(OptionError,
"MissingArgument",option);
1295 resource_info.text_font=XGetResourceClass(resource_database,
1296 GetClientName(),
"font",argv[i]);
1299 if (LocaleCompare(
"thumbnail",option+1) == 0)
1304 if (i == (ssize_t) argc)
1305 ThrowAnimateException(OptionError,
"MissingArgument",option);
1306 if (IsGeometry(argv[i]) == MagickFalse)
1307 ThrowAnimateInvalidArgumentException(option,argv[i]);
1310 if (LocaleCompare(
"title",option+1) == 0)
1312 resource_info.title=(
char *) NULL;
1316 if (i == (ssize_t) argc)
1317 ThrowAnimateException(OptionError,
"MissingArgument",option);
1318 resource_info.title=argv[i];
1321 if (LocaleCompare(
"transparent-color",option+1) == 0)
1326 if (i == (ssize_t) argc)
1327 ThrowAnimateException(OptionError,
"MissingArgument",option);
1330 if (LocaleCompare(
"treedepth",option+1) == 0)
1332 quantize_info->tree_depth=0;
1336 if (i == (ssize_t) argc)
1337 ThrowAnimateException(OptionError,
"MissingArgument",option);
1338 if (IsGeometry(argv[i]) == MagickFalse)
1339 ThrowAnimateInvalidArgumentException(option,argv[i]);
1340 quantize_info->tree_depth=StringToUnsignedLong(argv[i]);
1343 if (LocaleCompare(
"trim",option+1) == 0)
1345 ThrowAnimateException(OptionError,
"UnrecognizedOption",option);
1349 if (LocaleCompare(
"verbose",option+1) == 0)
1351 if ((LocaleCompare(
"version",option+1) == 0) ||
1352 (LocaleCompare(
"-version",option+1) == 0))
1354 ListMagickVersion(stdout);
1357 if (LocaleCompare(
"virtual-pixel",option+1) == 0)
1365 if (i == (ssize_t) argc)
1366 ThrowAnimateException(OptionError,
"MissingArgument",option);
1367 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
1370 ThrowAnimateException(OptionError,
1371 "UnrecognizedVirtualPixelMethod",argv[i]);
1374 if (LocaleCompare(
"visual",option+1) == 0)
1376 resource_info.visual_type=(
char *) NULL;
1380 if (i == (ssize_t) argc)
1381 ThrowAnimateException(OptionError,
"MissingArgument",option);
1382 resource_info.visual_type=argv[i];
1385 ThrowAnimateException(OptionError,
"UnrecognizedOption",option);
1389 if (LocaleCompare(
"window",option+1) == 0)
1391 resource_info.window_id=(
char *) NULL;
1395 if (i == (ssize_t) argc)
1396 ThrowAnimateException(OptionError,
"MissingArgument",option);
1397 resource_info.window_id=argv[i];
1400 ThrowAnimateException(OptionError,
"UnrecognizedOption",option);
1405 ThrowAnimateException(OptionError,
"UnrecognizedOption",option);
1407 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
1408 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
1409 if (fire != MagickFalse)
1410 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
1414 ThrowAnimateException(OptionError,
"UnbalancedParenthesis",argv[i]);
1415 if (image == (Image *) NULL)
1416 ThrowAnimateException(OptionError,
"MissingAnImageFilename",argv[argc-1])
1417 FinalizeImageSettings(image_info,image,MagickTrue);
1418 if (image == (Image *) NULL)
1419 ThrowAnimateException(OptionError,"MissingAnImageFilename",argv[argc-1])
1420 if (resource_info.window_id != (
char *) NULL)
1422 XAnimateBackgroundImage(display,&resource_info,image,exception);
1423 status&=(MagickStatusType) MagickTrue;
1433 animate_image=XAnimateImages(display,&resource_info,argv,argc,image,
1435 while (animate_image != (Image *) NULL)
1437 image=animate_image;
1438 animate_image=XAnimateImages(display,&resource_info,argv,argc,image,
1440 if (animate_image != image)
1441 image=DestroyImageList(image);
1445 return(status != 0 ? MagickTrue : MagickFalse);
1447WandExport MagickBooleanType AnimateImageCommand(ImageInfo *image_info,
1448 int wand_unused(argc),
char **wand_unused(argv),
char **wand_unused(metadata),
1449 ExceptionInfo *exception)
1451 wand_unreferenced(argc);
1452 wand_unreferenced(argv);
1453 wand_unreferenced(metadata);
1454 (void) ThrowMagickException(exception,GetMagickModule(),MissingDelegateError,
1455 "DelegateLibrarySupportNotBuiltIn",
"'%s' (X11)",image_info->filename);
1456 return(AnimateUsage());