blob: fbfe5b5a878fb02e5f9e9f401c6b2c549cbf23f9 [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001/*
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3% %
4% %
5% %
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 %
11% %
12% %
13% Methods to Interactively Animate an Image Sequence %
14% %
15% Software Design %
cristyde984cd2013-12-01 14:49:27 +000016% Cristy %
cristy3ed852e2009-09-05 21:47:34 +000017% July 1992 %
18% %
19% %
Cristyf6ff9ea2016-12-05 09:53:35 -050020% Copyright 1999-2017 ImageMagick Studio LLC, a non-profit organization %
cristy3ed852e2009-09-05 21:47:34 +000021% dedicated to making software imaging solutions freely available. %
22% %
23% You may not use this file except in compliance with the License. You may %
24% obtain a copy of the License at %
25% %
26% http://www.imagemagick.org/script/license.php %
27% %
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. %
33% %
34%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35%
36% Use the animate program to animate an image sequence on any X server.
37%
38*/
39
40/*
41 Include declarations.
42*/
cristy4c08aed2011-07-01 19:47:50 +000043#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"
cristy3ed852e2009-09-05 21:47:34 +000048
49/*
50%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
51% %
52% %
53% %
54+ A n i m a t e I m a g e C o m m a n d %
55% %
56% %
57% %
58%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59%
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
66% displayed.
67%
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
72% device.
73%
74% The format of the AnimateImageCommand method is:
75%
76% MagickBooleanType AnimateImageCommand(ImageInfo *image_info,int argc,
77% char **argv,char **metadata,ExceptionInfo *exception)
78%
79% A description of each parameter follows:
80%
81% o image_info: the image info.
82%
83% o argc: the number of elements in the argument vector.
84%
85% o argv: A text array containing the command line arguments.
86%
87% o metadata: any metadata is returned here.
88%
89% o exception: return any errors or warnings in this structure.
90%
91*/
92
93static MagickBooleanType AnimateUsage(void)
94{
95 const char
96 **p;
97
98 static const char
99 *buttons[]=
100 {
101 "Press any button to map or unmap the Command widget",
102 (char *) NULL
103 },
104 *miscellaneous[]=
105 {
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",
111 (char *) NULL
112 },
113 *operators[]=
114 {
cristy17ada022014-11-07 22:12:23 +0000115 "-channel mask set the image channel mask",
cristy3ed852e2009-09-05 21:47:34 +0000116 "-colors value preferred number of colors in the image",
117 "-crop geometry preferred size and location of the cropped image",
118 "-extract geometry extract area from image",
119 "-monochrome transform image to black and white",
120 "-repage geometry size and location of an image canvas (operator)",
121 "-resample geometry change the resolution of an image",
122 "-resize geometry resize the image",
123 "-rotate degrees apply Paeth rotation to the image",
124 "-strip strip image of all profiles and comments",
cristye4cbe742010-02-18 22:19:38 +0000125 "-thumbnail geometry create a thumbnail of the image",
cristy3ed852e2009-09-05 21:47:34 +0000126 "-trim trim image edges",
127 (char *) NULL
128 },
129 *settings[]=
130 {
131 "-alpha option on, activate, off, deactivate, set, opaque, copy",
132 " transparent, extract, background, or shape",
133 "-authenticate password",
134 " decipher image with this password",
135 "-backdrop display image centered on a backdrop",
cristy3ed852e2009-09-05 21:47:34 +0000136 "-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",
cristye9252c22013-07-30 15:43:21 +0000158 "-matte store matte channel if the image has one",
cristy3ed852e2009-09-05 21:47:34 +0000159 "-map type display image using this Standard Colormap",
160 "-monitor monitor progress",
161 "-pause seconds to pause before reanimating",
162 "-page geometry size and location of an image canvas (setting)",
163 "-quantize colorspace reduce colors in this colorspace",
164 "-quiet suppress all warning messages",
165 "-regard-warnings pay attention to warning messages",
166 "-remote command execute a command in an remote display process",
167 "-respect-parentheses settings remain in effect until parenthesis boundary",
168 "-sampling-factor geometry",
169 " horizontal and vertical sampling factor",
cristye9252c22013-07-30 15:43:21 +0000170 "-scenes range image scene range",
cristy3ed852e2009-09-05 21:47:34 +0000171 "-seed value seed a new sequence of pseudo-random numbers",
172 "-set attribute value set an image attribute",
173 "-size geometry width and height of image",
cristye9252c22013-07-30 15:43:21 +0000174 "-support factor resize support: > 1.0 is blurry, < 1.0 is sharp",
cristy3ed852e2009-09-05 21:47:34 +0000175 "-transparent-color color",
176 " transparent color",
177 "-treedepth value color tree depth",
178 "-verbose print detailed information about the image",
179 "-visual type display image using this visual type",
180 "-virtual-pixel method",
181 " virtual pixel access method",
182 "-window id display image to background of this window",
183 (char *) NULL
184 },
185 *sequence_operators[]=
186 {
187 "-coalesce merge a sequence of images",
188 "-flatten flatten a sequence of images",
189 (char *) NULL
190 };
191
cristy4f7a6132012-12-23 00:35:19 +0000192 ListMagickVersion(stdout);
cristy3ed852e2009-09-05 21:47:34 +0000193 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
194 GetClientName());
195 (void) printf("\nImage Settings:\n");
196 for (p=settings; *p != (char *) NULL; p++)
197 (void) printf(" %s\n",*p);
198 (void) printf("\nImage Operators:\n");
199 for (p=operators; *p != (char *) NULL; p++)
200 (void) printf(" %s\n",*p);
201 (void) printf("\nImage Sequence Operators:\n");
202 for (p=sequence_operators; *p != (char *) NULL; p++)
203 (void) printf(" %s\n",*p);
204 (void) printf("\nMiscellaneous Options:\n");
205 for (p=miscellaneous; *p != (char *) NULL; p++)
206 (void) printf(" %s\n",*p);
207 (void) printf(
208 "\nIn addition to those listed above, you can specify these standard X\n");
209 (void) printf(
210 "resources as command line options: -background, -bordercolor,\n");
211 (void) printf(
Cristy18b27502017-02-16 07:29:19 -0500212 "-mattecolor, -borderwidth, -font, -foreground, -iconGeometry,\n");
dirkb797b2c2016-02-01 22:20:32 +0100213 (void) printf("-iconic, -name, -shared-memory, or -title.\n");
cristy3ed852e2009-09-05 21:47:34 +0000214 (void) printf(
anthonye5b39652012-04-21 05:37:29 +0000215 "\nBy default, the image format of 'file' is determined by its magic\n");
cristy3ed852e2009-09-05 21:47:34 +0000216 (void) printf(
217 "number. To specify a particular image format, precede the filename\n");
218 (void) printf(
219 "with an image format name and a colon (i.e. ps:image) or specify the\n");
220 (void) printf(
221 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
222 (void) printf("'-' for standard input or output.\n");
223 (void) printf("\nButtons: \n");
224 for (p=buttons; *p != (char *) NULL; p++)
225 (void) printf(" %s\n",*p);
226 return(MagickFalse);
227}
228
229WandExport MagickBooleanType AnimateImageCommand(ImageInfo *image_info,
230 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
231{
232#if defined(MAGICKCORE_X11_DELEGATE)
233#define DestroyAnimate() \
234{ \
235 XDestroyResourceInfo(&resource_info); \
236 if (display != (Display *) NULL) \
237 { \
238 XCloseDisplay(display); \
239 display=(Display *) NULL; \
240 } \
241 XDestroyResourceInfo(&resource_info); \
242 DestroyImageStack(); \
cristybb503372010-05-27 20:51:26 +0000243 for (i=0; i < (ssize_t) argc; i++) \
cristy3ed852e2009-09-05 21:47:34 +0000244 argv[i]=DestroyString(argv[i]); \
245 argv=(char **) RelinquishMagickMemory(argv); \
246}
247#define ThrowAnimateException(asperity,tag,option) \
248{ \
cristyefe601c2013-01-05 17:51:12 +0000249 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
cristy3ed852e2009-09-05 21:47:34 +0000250 option); \
251 DestroyAnimate(); \
252 return(MagickFalse); \
253}
254#define ThrowAnimateInvalidArgumentException(option,argument) \
255{ \
256 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
anthonye5b39652012-04-21 05:37:29 +0000257 "InvalidArgument","'%s': %s",option,argument); \
cristy3ed852e2009-09-05 21:47:34 +0000258 DestroyAnimate(); \
259 return(MagickFalse); \
260}
261
262 char
263 *resource_value,
264 *server_name;
265
266 const char
267 *option;
268
269 Display
270 *display;
271
272 Image
273 *image;
274
275 ImageStack
276 image_stack[MaxImageStackDepth+1];
277
cristy3ed852e2009-09-05 21:47:34 +0000278 MagickBooleanType
279 fire,
cristyebbcfea2011-02-25 02:43:54 +0000280 pend,
281 respect_parenthesis;
cristy3ed852e2009-09-05 21:47:34 +0000282
283 MagickStatusType
284 status;
285
286 QuantizeInfo
287 *quantize_info;
288
cristybb503372010-05-27 20:51:26 +0000289 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000290 i;
291
cristy5ed838e2010-05-31 00:05:35 +0000292 ssize_t
293 j,
294 k;
295
cristy3ed852e2009-09-05 21:47:34 +0000296 XResourceInfo
297 resource_info;
298
299 XrmDatabase
300 resource_database;
301
302 /*
303 Set defaults.
304 */
305 assert(image_info != (ImageInfo *) NULL);
cristye1c94d92015-06-28 12:16:33 +0000306 assert(image_info->signature == MagickCoreSignature);
cristy3ed852e2009-09-05 21:47:34 +0000307 if (image_info->debug != MagickFalse)
308 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
309 assert(exception != (ExceptionInfo *) NULL);
310 if (argc == 2)
311 {
312 option=argv[1];
313 if ((LocaleCompare("version",option+1) == 0) ||
314 (LocaleCompare("-version",option+1) == 0))
315 {
cristy4f7a6132012-12-23 00:35:19 +0000316 ListMagickVersion(stdout);
Cristydf0b2912016-05-17 16:00:28 -0400317 return(MagickTrue);
cristy3ed852e2009-09-05 21:47:34 +0000318 }
319 }
320 status=MagickTrue;
321 SetNotifyHandlers;
322 display=(Display *) NULL;
323 j=1;
324 k=0;
325 NewImageStack();
326 option=(char *) NULL;
327 pend=MagickFalse;
cristyebbcfea2011-02-25 02:43:54 +0000328 respect_parenthesis=MagickFalse;
cristy3ed852e2009-09-05 21:47:34 +0000329 resource_database=(XrmDatabase) NULL;
330 (void) ResetMagickMemory(&resource_info,0,sizeof(XResourceInfo));
331 server_name=(char *) NULL;
332 status=MagickTrue;
333 /*
334 Check for server name specified on the command line.
335 */
336 ReadCommandlLine(argc,&argv);
337 status=ExpandFilenames(&argc,&argv);
338 if (status == MagickFalse)
339 ThrowAnimateException(ResourceLimitError,"MemoryAllocationFailed",
340 image_info->filename);
cristybb503372010-05-27 20:51:26 +0000341 for (i=1; i < (ssize_t) argc; i++)
cristy3ed852e2009-09-05 21:47:34 +0000342 {
343 /*
344 Check command line for server name.
345 */
346 option=argv[i];
347 if (LocaleCompare("display",option+1) == 0)
348 {
349 /*
350 User specified server name.
351 */
352 i++;
cristybb503372010-05-27 20:51:26 +0000353 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000354 ThrowAnimateException(OptionError,"MissingArgument",option);
355 server_name=argv[i];
356 }
357 if ((LocaleCompare("help",option+1) == 0) ||
358 (LocaleCompare("-help",option+1) == 0))
359 return(AnimateUsage());
360 }
361 /*
362 Get user defaults from X resource database.
363 */
364 display=XOpenDisplay(server_name);
365 if (display == (Display *) NULL)
366 ThrowAnimateException(XServerError,"UnableToOpenXServer",
367 XDisplayName(server_name));
368 (void) XSetErrorHandler(XError);
369 resource_database=XGetResourceDatabase(display,GetClientName());
370 XGetResourceInfo(image_info,resource_database,GetClientName(),
371 &resource_info);
372 quantize_info=resource_info.quantize_info;
373 image_info->density=XGetResourceInstance(resource_database,GetClientName(),
374 "density",(char *) NULL);
375 if (image_info->density == (char *) NULL)
376 image_info->density=XGetScreenDensity(display);
377 resource_value=XGetResourceInstance(resource_database,GetClientName(),
378 "interlace","none");
379 image_info->interlace=(InterlaceType)
cristy042ee782011-04-22 18:48:30 +0000380 ParseCommandOption(MagickInterlaceOptions,MagickFalse,resource_value);
cristy3ed852e2009-09-05 21:47:34 +0000381 resource_value=XGetResourceInstance(resource_database,GetClientName(),
382 "verbose","False");
anthony2e4501b2012-03-30 04:41:54 +0000383 image_info->verbose=IsStringTrue(resource_value);
cristy3ed852e2009-09-05 21:47:34 +0000384 resource_value=XGetResourceInstance(resource_database,GetClientName(),
385 "dither","True");
cristycbda6112012-05-27 20:57:16 +0000386 quantize_info->dither_method=IsStringTrue(resource_value) != MagickFalse ?
387 RiemersmaDitherMethod : NoDitherMethod;
cristy3ed852e2009-09-05 21:47:34 +0000388 /*
389 Parse command line.
390 */
cristybb503372010-05-27 20:51:26 +0000391 for (i=1; i <= (ssize_t) argc; i++)
cristy3ed852e2009-09-05 21:47:34 +0000392 {
cristybb503372010-05-27 20:51:26 +0000393 if (i < (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000394 option=argv[i];
395 else
396 if (image != (Image *) NULL)
397 break;
398 else
399 if (isatty(STDIN_FILENO) != MagickFalse)
400 option="logo:";
401 else
cristyb3ed35e2014-06-17 22:48:41 +0000402 option="-";
cristy3ed852e2009-09-05 21:47:34 +0000403 if (LocaleCompare(option,"(") == 0)
404 {
405 FireImageStack(MagickFalse,MagickTrue,pend);
406 if (k == MaxImageStackDepth)
407 ThrowAnimateException(OptionError,"ParenthesisNestedTooDeeply",
408 option);
409 PushImageStack();
410 continue;
411 }
412 if (LocaleCompare(option,")") == 0)
413 {
414 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
415 if (k == 0)
416 ThrowAnimateException(OptionError,"UnableToParseExpression",option);
417 PopImageStack();
418 continue;
419 }
cristy042ee782011-04-22 18:48:30 +0000420 if (IsCommandOption(option) == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +0000421 {
422 const char
423 *filename;
424
425 Image
426 *images;
427
428 /*
429 Read input image.
430 */
431 FireImageStack(MagickFalse,MagickFalse,pend);
432 filename=option;
cristycee97112010-05-28 00:44:52 +0000433 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
cristy3ed852e2009-09-05 21:47:34 +0000434 {
435 option=argv[++i];
436 filename=option;
437 }
cristy3ed852e2009-09-05 21:47:34 +0000438 if (image_info->ping != MagickFalse)
cristy1b58f252012-03-01 01:41:41 +0000439 images=PingImages(image_info,filename,exception);
cristy3ed852e2009-09-05 21:47:34 +0000440 else
cristy1b58f252012-03-01 01:41:41 +0000441 images=ReadImages(image_info,filename,exception);
cristy3ed852e2009-09-05 21:47:34 +0000442 status&=(images != (Image *) NULL) &&
443 (exception->severity < ErrorException);
444 if (images == (Image *) NULL)
445 continue;
446 AppendImageStack(images);
447 continue;
448 }
449 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
450 switch (*(option+1))
451 {
452 case 'a':
453 {
454 if (LocaleCompare("alpha",option+1) == 0)
455 {
cristybb503372010-05-27 20:51:26 +0000456 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000457 type;
458
459 if (*option == '+')
460 break;
461 i++;
cristybb503372010-05-27 20:51:26 +0000462 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000463 ThrowAnimateException(OptionError,"MissingArgument",option);
Cristyf895ba22016-12-25 10:47:46 -0500464 type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,
465 argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000466 if (type < 0)
Cristyf895ba22016-12-25 10:47:46 -0500467 ThrowAnimateException(OptionError,
468 "UnrecognizedAlphaChannelOption",argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000469 break;
470 }
471 if (LocaleCompare("authenticate",option+1) == 0)
472 {
473 if (*option == '+')
474 break;
475 i++;
cristybb503372010-05-27 20:51:26 +0000476 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000477 ThrowAnimateException(OptionError,"MissingArgument",option);
478 break;
479 }
480 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
481 }
482 case 'b':
483 {
484 if (LocaleCompare("backdrop",option+1) == 0)
485 {
486 resource_info.backdrop=(*option == '-') ? MagickTrue : MagickFalse;
487 break;
488 }
489 if (LocaleCompare("background",option+1) == 0)
490 {
491 if (*option == '+')
492 break;
493 i++;
cristybb503372010-05-27 20:51:26 +0000494 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000495 ThrowAnimateException(OptionError,"MissingArgument",option);
496 resource_info.background_color=argv[i];
497 break;
498 }
499 if (LocaleCompare("bordercolor",option+1) == 0)
500 {
501 if (*option == '+')
502 break;
503 i++;
cristybb503372010-05-27 20:51:26 +0000504 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000505 ThrowAnimateException(OptionError,"MissingArgument",option);
506 resource_info.border_color=argv[i];
507 break;
508 }
509 if (LocaleCompare("borderwidth",option+1) == 0)
510 {
511 resource_info.border_width=0;
512 if (*option == '+')
513 break;
514 i++;
cristybb503372010-05-27 20:51:26 +0000515 if ((i == (ssize_t) argc) || (IsGeometry(argv[i]) == MagickFalse))
cristy3ed852e2009-09-05 21:47:34 +0000516 ThrowAnimateException(OptionError,"MissingArgument",option);
cristye27293e2009-12-18 02:53:20 +0000517 resource_info.border_width=(unsigned int)
518 StringToUnsignedLong(argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000519 break;
520 }
521 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
522 }
523 case 'c':
524 {
525 if (LocaleCompare("cache",option+1) == 0)
526 {
527 if (*option == '+')
528 break;
529 i++;
cristybb503372010-05-27 20:51:26 +0000530 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000531 ThrowAnimateException(OptionError,"MissingArgument",option);
532 if (IsGeometry(argv[i]) == MagickFalse)
533 ThrowAnimateInvalidArgumentException(option,argv[i]);
534 break;
535 }
536 if (LocaleCompare("channel",option+1) == 0)
537 {
cristybb503372010-05-27 20:51:26 +0000538 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000539 channel;
540
541 if (*option == '+')
542 break;
543 i++;
cristye81f5522014-05-07 01:25:59 +0000544 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000545 ThrowAnimateException(OptionError,"MissingArgument",option);
546 channel=ParseChannelOption(argv[i]);
547 if (channel < 0)
548 ThrowAnimateException(OptionError,"UnrecognizedChannelType",
549 argv[i]);
550 break;
551 }
552 if (LocaleCompare("clone",option+1) == 0)
553 {
554 Image
555 *clone_images;
556
557 clone_images=image;
558 if (k != 0)
559 clone_images=image_stack[k-1].image;
560 if (clone_images == (Image *) NULL)
anthony8226e722012-04-05 14:25:46 +0000561 ThrowAnimateException(ImageError,"UnableToCloneImage",option);
cristy3ed852e2009-09-05 21:47:34 +0000562 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
563 if (*option == '+')
564 clone_images=CloneImages(clone_images,"-1",exception);
565 else
566 {
567 i++;
cristye81f5522014-05-07 01:25:59 +0000568 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000569 ThrowAnimateException(OptionError,"MissingArgument",option);
570 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
571 ThrowAnimateInvalidArgumentException(option,argv[i]);
572 clone_images=CloneImages(clone_images,argv[i],exception);
573 }
574 if (clone_images == (Image *) NULL)
575 ThrowAnimateException(OptionError,"NoSuchImage",option);
576 AppendImageStack(clone_images);
577 break;
578 }
579 if (LocaleCompare("coalesce",option+1) == 0)
580 break;
581 if (LocaleCompare("colormap",option+1) == 0)
582 {
583 resource_info.colormap=PrivateColormap;
584 if (*option == '+')
585 break;
586 i++;
cristybb503372010-05-27 20:51:26 +0000587 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000588 ThrowAnimateException(OptionError,"MissingArgument",option);
589 resource_info.colormap=UndefinedColormap;
590 if (LocaleCompare("private",argv[i]) == 0)
591 resource_info.colormap=PrivateColormap;
592 if (LocaleCompare("shared",argv[i]) == 0)
593 resource_info.colormap=SharedColormap;
594 if (resource_info.colormap == UndefinedColormap)
595 ThrowAnimateException(OptionError,"UnrecognizedColormapType",
596 argv[i]);
597 break;
598 }
599 if (LocaleCompare("colors",option+1) == 0)
600 {
601 quantize_info->number_colors=0;
602 if (*option == '+')
603 break;
604 i++;
cristybb503372010-05-27 20:51:26 +0000605 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000606 ThrowAnimateException(OptionError,"MissingArgument",option);
607 if (IsGeometry(argv[i]) == MagickFalse)
608 ThrowAnimateInvalidArgumentException(option,argv[i]);
cristye27293e2009-12-18 02:53:20 +0000609 quantize_info->number_colors=StringToUnsignedLong(argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000610 break;
611 }
612 if (LocaleCompare("colorspace",option+1) == 0)
613 {
cristybb503372010-05-27 20:51:26 +0000614 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000615 colorspace;
616
617 if (*option == '+')
618 break;
619 i++;
cristybb503372010-05-27 20:51:26 +0000620 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000621 ThrowAnimateException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000622 colorspace=ParseCommandOption(MagickColorspaceOptions,
cristy3ed852e2009-09-05 21:47:34 +0000623 MagickFalse,argv[i]);
624 if (colorspace < 0)
625 ThrowAnimateException(OptionError,"UnrecognizedColorspace",
626 argv[i]);
627 break;
628 }
cristy22879752009-10-25 23:55:40 +0000629 if (LocaleCompare("concurrent",option+1) == 0)
630 break;
cristy3ed852e2009-09-05 21:47:34 +0000631 if (LocaleCompare("crop",option+1) == 0)
632 {
633 if (*option == '+')
634 break;
635 i++;
cristybb503372010-05-27 20:51:26 +0000636 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000637 ThrowAnimateException(OptionError,"MissingArgument",option);
638 if (IsGeometry(argv[i]) == MagickFalse)
639 ThrowAnimateInvalidArgumentException(option,argv[i]);
640 break;
641 }
642 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
643 }
644 case 'd':
645 {
646 if (LocaleCompare("debug",option+1) == 0)
647 {
cristybb503372010-05-27 20:51:26 +0000648 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000649 event;
650
651 if (*option == '+')
652 break;
653 i++;
cristybb503372010-05-27 20:51:26 +0000654 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000655 ThrowAnimateException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000656 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000657 if (event < 0)
658 ThrowAnimateException(OptionError,"UnrecognizedEventType",
659 argv[i]);
660 (void) SetLogEventMask(argv[i]);
661 break;
662 }
663 if (LocaleCompare("decipher",option+1) == 0)
664 {
665 if (*option == '+')
666 break;
667 i++;
cristye81f5522014-05-07 01:25:59 +0000668 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000669 ThrowAnimateException(OptionError,"MissingArgument",option);
670 break;
671 }
672 if (LocaleCompare("define",option+1) == 0)
673 {
674 i++;
cristybb503372010-05-27 20:51:26 +0000675 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000676 ThrowAnimateException(OptionError,"MissingArgument",option);
677 if (*option == '+')
678 {
679 const char
680 *define;
681
682 define=GetImageOption(image_info,argv[i]);
683 if (define == (const char *) NULL)
684 ThrowAnimateException(OptionError,"NoSuchOption",argv[i]);
685 break;
686 }
687 break;
688 }
689 if (LocaleCompare("delay",option+1) == 0)
690 {
691 if (*option == '+')
692 break;
693 i++;
cristybb503372010-05-27 20:51:26 +0000694 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000695 ThrowAnimateException(OptionError,"MissingArgument",option);
696 if (IsGeometry(argv[i]) == MagickFalse)
697 ThrowAnimateInvalidArgumentException(option,argv[i]);
698 break;
699 }
700 if (LocaleCompare("density",option+1) == 0)
701 {
702 if (*option == '+')
703 break;
704 i++;
cristybb503372010-05-27 20:51:26 +0000705 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000706 ThrowAnimateException(OptionError,"MissingArgument",option);
707 if (IsGeometry(argv[i]) == MagickFalse)
708 ThrowAnimateInvalidArgumentException(option,argv[i]);
709 break;
710 }
711 if (LocaleCompare("depth",option+1) == 0)
712 {
713 if (*option == '+')
714 break;
715 i++;
cristybb503372010-05-27 20:51:26 +0000716 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000717 ThrowAnimateException(OptionError,"MissingArgument",option);
718 if (IsGeometry(argv[i]) == MagickFalse)
719 ThrowAnimateInvalidArgumentException(option,argv[i]);
720 break;
721 }
722 if (LocaleCompare("display",option+1) == 0)
723 {
724 if (*option == '+')
725 break;
726 i++;
cristybb503372010-05-27 20:51:26 +0000727 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000728 ThrowAnimateException(OptionError,"MissingArgument",option);
729 break;
730 }
731 if (LocaleCompare("dispose",option+1) == 0)
732 {
cristybb503372010-05-27 20:51:26 +0000733 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000734 dispose;
735
736 if (*option == '+')
737 break;
738 i++;
cristybb503372010-05-27 20:51:26 +0000739 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000740 ThrowAnimateException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000741 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000742 if (dispose < 0)
743 ThrowAnimateException(OptionError,"UnrecognizedDisposeMethod",
744 argv[i]);
745 break;
746 }
747 if (LocaleCompare("dither",option+1) == 0)
748 {
cristybb503372010-05-27 20:51:26 +0000749 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000750 method;
751
cristycbda6112012-05-27 20:57:16 +0000752 quantize_info->dither_method=NoDitherMethod;
cristy3ed852e2009-09-05 21:47:34 +0000753 if (*option == '+')
754 break;
755 i++;
cristybb503372010-05-27 20:51:26 +0000756 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000757 ThrowAnimateException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000758 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000759 if (method < 0)
760 ThrowAnimateException(OptionError,"UnrecognizedDitherMethod",
761 argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000762 quantize_info->dither_method=(DitherMethod) method;
763 break;
764 }
cristy22879752009-10-25 23:55:40 +0000765 if (LocaleCompare("duration",option+1) == 0)
766 {
767 if (*option == '+')
768 break;
769 i++;
cristye81f5522014-05-07 01:25:59 +0000770 if (i == (ssize_t) argc)
cristy22879752009-10-25 23:55:40 +0000771 ThrowAnimateException(OptionError,"MissingArgument",option);
772 if (IsGeometry(argv[i]) == MagickFalse)
773 ThrowAnimateInvalidArgumentException(option,argv[i]);
774 break;
775 }
cristy3ed852e2009-09-05 21:47:34 +0000776 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
777 }
778 case 'e':
779 {
780 if (LocaleCompare("extract",option+1) == 0)
781 {
782 if (*option == '+')
783 break;
784 i++;
cristybb503372010-05-27 20:51:26 +0000785 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000786 ThrowAnimateException(OptionError,"MissingArgument",option);
787 if (IsGeometry(argv[i]) == MagickFalse)
788 ThrowAnimateInvalidArgumentException(option,argv[i]);
789 break;
790 }
791 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
792 }
793 case 'f':
794 {
795 if (LocaleCompare("filter",option+1) == 0)
796 {
cristybb503372010-05-27 20:51:26 +0000797 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000798 filter;
799
800 if (*option == '+')
801 break;
802 i++;
cristye81f5522014-05-07 01:25:59 +0000803 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000804 ThrowAnimateException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000805 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000806 if (filter < 0)
807 ThrowAnimateException(OptionError,"UnrecognizedImageFilter",
808 argv[i]);
809 break;
810 }
811 if (LocaleCompare("flatten",option+1) == 0)
812 break;
813 if (LocaleCompare("font",option+1) == 0)
814 {
815 if (*option == '+')
816 break;
817 i++;
cristybb503372010-05-27 20:51:26 +0000818 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000819 ThrowAnimateException(OptionError,"MissingArgument",option);
820 resource_info.font=XGetResourceClass(resource_database,
821 GetClientName(),"font",argv[i]);
822 break;
823 }
824 if (LocaleCompare("foreground",option+1) == 0)
825 {
826 if (*option == '+')
827 break;
828 i++;
cristybb503372010-05-27 20:51:26 +0000829 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000830 ThrowAnimateException(OptionError,"MissingArgument",option);
831 resource_info.foreground_color=argv[i];
832 break;
833 }
834 if (LocaleCompare("format",option+1) == 0)
835 {
836 if (*option == '+')
837 break;
838 i++;
cristye81f5522014-05-07 01:25:59 +0000839 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000840 ThrowAnimateException(OptionError,"MissingArgument",option);
841 break;
842 }
843 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
844 }
845 case 'g':
846 {
847 if (LocaleCompare("gamma",option+1) == 0)
848 {
849 i++;
cristybb503372010-05-27 20:51:26 +0000850 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000851 ThrowAnimateException(OptionError,"MissingArgument",option);
852 if (IsGeometry(argv[i]) == MagickFalse)
853 ThrowAnimateInvalidArgumentException(option,argv[i]);
854 break;
855 }
856 if (LocaleCompare("geometry",option+1) == 0)
857 {
858 resource_info.image_geometry=(char *) NULL;
859 if (*option == '+')
860 break;
861 i++;
cristybb503372010-05-27 20:51:26 +0000862 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000863 ThrowAnimateException(OptionError,"MissingArgument",option);
864 if (IsGeometry(argv[i]) == MagickFalse)
865 ThrowAnimateInvalidArgumentException(option,argv[i]);
866 resource_info.image_geometry=ConstantString(argv[i]);
867 break;
868 }
869 if (LocaleCompare("gravity",option+1) == 0)
870 {
cristybb503372010-05-27 20:51:26 +0000871 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000872 gravity;
873
874 if (*option == '+')
875 break;
876 i++;
cristye81f5522014-05-07 01:25:59 +0000877 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000878 ThrowAnimateException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000879 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +0000880 argv[i]);
881 if (gravity < 0)
882 ThrowAnimateException(OptionError,"UnrecognizedGravityType",
883 argv[i]);
884 break;
885 }
886 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
887 }
888 case 'h':
889 {
890 if ((LocaleCompare("help",option+1) == 0) ||
891 (LocaleCompare("-help",option+1) == 0))
892 break;
893 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
894 }
895 case 'i':
896 {
897 if (LocaleCompare("iconGeometry",option+1) == 0)
898 {
899 resource_info.icon_geometry=(char *) NULL;
900 if (*option == '+')
901 break;
902 i++;
cristybb503372010-05-27 20:51:26 +0000903 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000904 ThrowAnimateException(OptionError,"MissingArgument",option);
905 if (IsGeometry(argv[i]) == MagickFalse)
906 ThrowAnimateInvalidArgumentException(option,argv[i]);
907 resource_info.icon_geometry=argv[i];
908 break;
909 }
910 if (LocaleCompare("iconic",option+1) == 0)
911 {
912 resource_info.iconic=(*option == '-') ? MagickTrue : MagickFalse;
913 break;
914 }
915 if (LocaleCompare("identify",option+1) == 0)
916 break;
917 if (LocaleCompare("immutable",option+1) == 0)
918 {
919 resource_info.immutable=(*option == '-') ? MagickTrue : MagickFalse;
920 break;
921 }
922 if (LocaleCompare("interlace",option+1) == 0)
923 {
cristybb503372010-05-27 20:51:26 +0000924 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000925 interlace;
926
927 if (*option == '+')
928 break;
929 i++;
cristybb503372010-05-27 20:51:26 +0000930 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000931 ThrowAnimateException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000932 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +0000933 argv[i]);
934 if (interlace < 0)
935 ThrowAnimateException(OptionError,"UnrecognizedInterlaceType",
936 argv[i]);
937 break;
938 }
939 if (LocaleCompare("interpolate",option+1) == 0)
940 {
cristybb503372010-05-27 20:51:26 +0000941 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000942 interpolate;
943
944 if (*option == '+')
945 break;
946 i++;
cristybb503372010-05-27 20:51:26 +0000947 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000948 ThrowAnimateException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000949 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +0000950 argv[i]);
951 if (interpolate < 0)
952 ThrowAnimateException(OptionError,"UnrecognizedInterpolateMethod",
953 argv[i]);
954 break;
955 }
956 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
957 }
958 case 'l':
959 {
960 if (LocaleCompare("label",option+1) == 0)
961 {
962 if (*option == '+')
963 break;
964 i++;
cristybb503372010-05-27 20:51:26 +0000965 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000966 ThrowAnimateException(OptionError,"MissingArgument",option);
967 break;
968 }
969 if (LocaleCompare("limit",option+1) == 0)
970 {
971 char
972 *p;
973
974 double
975 value;
976
cristybb503372010-05-27 20:51:26 +0000977 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000978 resource;
979
980 if (*option == '+')
981 break;
982 i++;
cristybb503372010-05-27 20:51:26 +0000983 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000984 ThrowAnimateException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000985 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +0000986 argv[i]);
987 if (resource < 0)
988 ThrowAnimateException(OptionError,"UnrecognizedResourceType",
989 argv[i]);
990 i++;
cristybb503372010-05-27 20:51:26 +0000991 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000992 ThrowAnimateException(OptionError,"MissingArgument",option);
cristydbdd0e32011-11-04 23:29:40 +0000993 value=StringToDouble(argv[i],&p);
cristyda16f162011-02-19 23:52:17 +0000994 (void) value;
cristy3ed852e2009-09-05 21:47:34 +0000995 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
996 ThrowAnimateInvalidArgumentException(option,argv[i]);
997 break;
998 }
999 if (LocaleCompare("list",option+1) == 0)
1000 {
cristybb503372010-05-27 20:51:26 +00001001 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00001002 list;
1003
1004 if (*option == '+')
1005 break;
1006 i++;
cristybb503372010-05-27 20:51:26 +00001007 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001008 ThrowAnimateException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00001009 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00001010 if (list < 0)
1011 ThrowAnimateException(OptionError,"UnrecognizedListType",argv[i]);
cristyaeb2cbc2010-05-07 13:28:58 +00001012 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
cristy3ed852e2009-09-05 21:47:34 +00001013 argv+j,exception);
1014 DestroyAnimate();
cristy32ce2392014-09-24 19:08:53 +00001015 return(status == 0 ? MagickTrue : MagickFalse);
cristy3ed852e2009-09-05 21:47:34 +00001016 }
1017 if (LocaleCompare("log",option+1) == 0)
1018 {
1019 if (*option == '+')
1020 break;
1021 i++;
cristybb503372010-05-27 20:51:26 +00001022 if ((i == (ssize_t) argc) ||
cristy3ed852e2009-09-05 21:47:34 +00001023 (strchr(argv[i],'%') == (char *) NULL))
1024 ThrowAnimateException(OptionError,"MissingArgument",option);
1025 break;
1026 }
1027 if (LocaleCompare("loop",option+1) == 0)
1028 {
1029 if (*option == '+')
1030 break;
1031 i++;
cristye81f5522014-05-07 01:25:59 +00001032 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001033 ThrowAnimateException(OptionError,"MissingArgument",option);
1034 if (IsGeometry(argv[i]) == MagickFalse)
1035 ThrowAnimateInvalidArgumentException(option,argv[i]);
1036 break;
1037 }
1038 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1039 }
1040 case 'm':
1041 {
1042 if (LocaleCompare("map",option+1) == 0)
1043 {
1044 resource_info.map_type=(char *) NULL;
1045 if (*option == '+')
1046 break;
cristy151b66d2015-04-15 10:50:31 +00001047 (void) CopyMagickString(argv[i]+1,"san",MagickPathExtent);
cristy3ed852e2009-09-05 21:47:34 +00001048 i++;
cristybb503372010-05-27 20:51:26 +00001049 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001050 ThrowAnimateException(OptionError,"MissingArgument",option);
1051 resource_info.map_type=argv[i];
1052 break;
1053 }
1054 if (LocaleCompare("matte",option+1) == 0)
1055 break;
Cristy18b27502017-02-16 07:29:19 -05001056 if (LocaleCompare("mattecolor",option+1) == 0)
1057 {
1058 if (*option == '+')
1059 break;
1060 i++;
1061 if (i == (ssize_t) argc)
1062 ThrowAnimateException(OptionError,"MissingArgument",option);
1063 resource_info.matte_color=argv[i];
1064 break;
1065 }
cristy3ed852e2009-09-05 21:47:34 +00001066 if (LocaleCompare("monitor",option+1) == 0)
1067 break;
1068 if (LocaleCompare("monochrome",option+1) == 0)
1069 {
1070 if (*option == '+')
1071 break;
1072 quantize_info->number_colors=2;
1073 quantize_info->colorspace=GRAYColorspace;
1074 break;
1075 }
1076 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1077 }
1078 case 'n':
1079 {
1080 if (LocaleCompare("name",option+1) == 0)
1081 {
1082 resource_info.name=(char *) NULL;
1083 if (*option == '+')
1084 break;
1085 i++;
cristybb503372010-05-27 20:51:26 +00001086 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001087 ThrowAnimateException(OptionError,"MissingArgument",option);
1088 resource_info.name=ConstantString(argv[i]);
1089 break;
1090 }
1091 if (LocaleCompare("noop",option+1) == 0)
1092 break;
1093 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1094 }
1095 case 'p':
1096 {
1097 if (LocaleCompare("pause",option+1) == 0)
1098 {
1099 resource_info.pause=0;
1100 if (*option == '+')
1101 break;
1102 i++;
cristybb503372010-05-27 20:51:26 +00001103 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001104 ThrowAnimateException(OptionError,"MissingArgument",option);
1105 if (IsGeometry(argv[i]) == MagickFalse)
1106 ThrowAnimateInvalidArgumentException(option,argv[i]);
cristye27293e2009-12-18 02:53:20 +00001107 resource_info.pause=(unsigned int) StringToUnsignedLong(argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00001108 break;
1109 }
1110 if (LocaleCompare("page",option+1) == 0)
1111 {
1112 if (*option == '+')
1113 break;
1114 i++;
cristybb503372010-05-27 20:51:26 +00001115 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001116 ThrowAnimateException(OptionError,"MissingArgument",option);
1117 break;
1118 }
1119 if (LocaleCompare("profile",option+1) == 0)
1120 {
1121 i++;
cristybb503372010-05-27 20:51:26 +00001122 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001123 ThrowAnimateException(OptionError,"MissingArgument",option);
1124 break;
1125 }
1126 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1127 }
1128 case 'q':
1129 {
1130 if (LocaleCompare("quantize",option+1) == 0)
1131 {
cristybb503372010-05-27 20:51:26 +00001132 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00001133 colorspace;
1134
1135 if (*option == '+')
1136 break;
1137 i++;
cristye81f5522014-05-07 01:25:59 +00001138 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001139 ThrowAnimateException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00001140 colorspace=ParseCommandOption(MagickColorspaceOptions,
cristy3ed852e2009-09-05 21:47:34 +00001141 MagickFalse,argv[i]);
1142 if (colorspace < 0)
1143 ThrowAnimateException(OptionError,"UnrecognizedColorspace",
1144 argv[i]);
1145 break;
1146 }
1147 if (LocaleCompare("quiet",option+1) == 0)
1148 break;
1149 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1150 }
1151 case 'r':
1152 {
1153 if (LocaleCompare("regard-warnings",option+1) == 0)
1154 break;
1155 if (LocaleCompare("remote",option+1) == 0)
1156 {
1157 i++;
cristybb503372010-05-27 20:51:26 +00001158 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001159 ThrowAnimateException(OptionError,"MissingArgument",option);
1160 if (XRemoteCommand(display,resource_info.window_id,argv[i]) != 0)
1161 return(MagickFalse);
1162 i--;
1163 break;
1164 }
1165 if (LocaleCompare("repage",option+1) == 0)
1166 {
1167 if (*option == '+')
1168 break;
1169 i++;
cristybb503372010-05-27 20:51:26 +00001170 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001171 ThrowAnimateException(OptionError,"MissingArgument",option);
1172 if (IsGeometry(argv[i]) == MagickFalse)
1173 ThrowAnimateInvalidArgumentException(option,argv[i]);
1174 break;
1175 }
1176 if (LocaleCompare("resample",option+1) == 0)
1177 {
1178 if (*option == '+')
1179 break;
1180 i++;
cristye81f5522014-05-07 01:25:59 +00001181 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001182 ThrowAnimateException(OptionError,"MissingArgument",option);
1183 if (IsGeometry(argv[i]) == MagickFalse)
1184 ThrowAnimateInvalidArgumentException(option,argv[i]);
1185 break;
1186 }
1187 if (LocaleCompare("resize",option+1) == 0)
1188 {
1189 if (*option == '+')
1190 break;
1191 i++;
cristybb503372010-05-27 20:51:26 +00001192 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001193 ThrowAnimateException(OptionError,"MissingArgument",option);
1194 if (IsGeometry(argv[i]) == MagickFalse)
1195 ThrowAnimateInvalidArgumentException(option,argv[i]);
1196 break;
1197 }
1198 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
1199 {
1200 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
1201 break;
1202 }
1203 if (LocaleCompare("rotate",option+1) == 0)
1204 {
1205 i++;
cristybb503372010-05-27 20:51:26 +00001206 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001207 ThrowAnimateException(OptionError,"MissingArgument",option);
1208 if (IsGeometry(argv[i]) == MagickFalse)
1209 ThrowAnimateInvalidArgumentException(option,argv[i]);
1210 break;
1211 }
1212 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1213 }
1214 case 's':
1215 {
1216 if (LocaleCompare("sampling-factor",option+1) == 0)
1217 {
1218 if (*option == '+')
1219 break;
1220 i++;
cristybb503372010-05-27 20:51:26 +00001221 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001222 ThrowAnimateException(OptionError,"MissingArgument",option);
1223 if (IsGeometry(argv[i]) == MagickFalse)
1224 ThrowAnimateInvalidArgumentException(option,argv[i]);
1225 break;
1226 }
1227 if (LocaleCompare("seed",option+1) == 0)
1228 {
1229 if (*option == '+')
1230 break;
1231 i++;
cristye81f5522014-05-07 01:25:59 +00001232 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001233 ThrowAnimateException(OptionError,"MissingArgument",option);
1234 if (IsGeometry(argv[i]) == MagickFalse)
1235 ThrowAnimateInvalidArgumentException(option,argv[i]);
1236 break;
1237 }
1238 if (LocaleCompare("scenes",option+1) == 0) /* deprecated */
1239 {
1240 if (*option == '+')
1241 break;
1242 i++;
cristybb503372010-05-27 20:51:26 +00001243 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001244 ThrowAnimateException(OptionError,"MissingArgument",option);
1245 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
1246 ThrowAnimateInvalidArgumentException(option,argv[i]);
1247 break;
1248 }
1249 if (LocaleCompare("set",option+1) == 0)
1250 {
1251 i++;
cristybb503372010-05-27 20:51:26 +00001252 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001253 ThrowAnimateException(OptionError,"MissingArgument",option);
1254 if (*option == '+')
1255 break;
1256 i++;
cristybb503372010-05-27 20:51:26 +00001257 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001258 ThrowAnimateException(OptionError,"MissingArgument",option);
1259 break;
1260 }
1261 if (LocaleCompare("shared-memory",option+1) == 0)
1262 {
1263 resource_info.use_shared_memory=(*option == '-') ? MagickTrue :
1264 MagickFalse;
1265 break;
1266 }
1267 if (LocaleCompare("size",option+1) == 0)
1268 {
1269 if (*option == '+')
1270 break;
1271 i++;
cristybb503372010-05-27 20:51:26 +00001272 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001273 ThrowAnimateException(OptionError,"MissingArgument",option);
1274 if (IsGeometry(argv[i]) == MagickFalse)
1275 ThrowAnimateInvalidArgumentException(option,argv[i]);
1276 break;
1277 }
1278 if (LocaleCompare("strip",option+1) == 0)
1279 break;
1280 if (LocaleCompare("support",option+1) == 0)
1281 {
1282 i++; /* deprecated */
1283 break;
1284 }
1285 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1286 }
1287 case 't':
1288 {
1289 if (LocaleCompare("text-font",option+1) == 0)
1290 {
1291 resource_info.text_font=(char *) NULL;
1292 if (*option == '+')
1293 break;
1294 i++;
cristybb503372010-05-27 20:51:26 +00001295 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001296 ThrowAnimateException(OptionError,"MissingArgument",option);
1297 resource_info.text_font=XGetResourceClass(resource_database,
1298 GetClientName(),"font",argv[i]);
1299 break;
1300 }
1301 if (LocaleCompare("thumbnail",option+1) == 0)
1302 {
1303 if (*option == '+')
1304 break;
1305 i++;
cristybb503372010-05-27 20:51:26 +00001306 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001307 ThrowAnimateException(OptionError,"MissingArgument",option);
1308 if (IsGeometry(argv[i]) == MagickFalse)
1309 ThrowAnimateInvalidArgumentException(option,argv[i]);
1310 break;
1311 }
1312 if (LocaleCompare("title",option+1) == 0)
1313 {
1314 resource_info.title=(char *) NULL;
1315 if (*option == '+')
1316 break;
1317 i++;
cristybb503372010-05-27 20:51:26 +00001318 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001319 ThrowAnimateException(OptionError,"MissingArgument",option);
1320 resource_info.title=argv[i];
1321 break;
1322 }
1323 if (LocaleCompare("transparent-color",option+1) == 0)
1324 {
1325 if (*option == '+')
1326 break;
1327 i++;
cristye81f5522014-05-07 01:25:59 +00001328 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001329 ThrowAnimateException(OptionError,"MissingArgument",option);
1330 break;
1331 }
1332 if (LocaleCompare("treedepth",option+1) == 0)
1333 {
1334 quantize_info->tree_depth=0;
1335 if (*option == '+')
1336 break;
1337 i++;
cristybb503372010-05-27 20:51:26 +00001338 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001339 ThrowAnimateException(OptionError,"MissingArgument",option);
1340 if (IsGeometry(argv[i]) == MagickFalse)
1341 ThrowAnimateInvalidArgumentException(option,argv[i]);
cristye27293e2009-12-18 02:53:20 +00001342 quantize_info->tree_depth=StringToUnsignedLong(argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00001343 break;
1344 }
1345 if (LocaleCompare("trim",option+1) == 0)
1346 break;
1347 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1348 }
1349 case 'v':
1350 {
1351 if (LocaleCompare("verbose",option+1) == 0)
1352 break;
1353 if ((LocaleCompare("version",option+1) == 0) ||
1354 (LocaleCompare("-version",option+1) == 0))
1355 {
cristy4f7a6132012-12-23 00:35:19 +00001356 ListMagickVersion(stdout);
cristy3ed852e2009-09-05 21:47:34 +00001357 break;
1358 }
1359 if (LocaleCompare("virtual-pixel",option+1) == 0)
1360 {
cristybb503372010-05-27 20:51:26 +00001361 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00001362 method;
1363
1364 if (*option == '+')
1365 break;
1366 i++;
cristybb503372010-05-27 20:51:26 +00001367 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001368 ThrowAnimateException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00001369 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00001370 argv[i]);
1371 if (method < 0)
1372 ThrowAnimateException(OptionError,
1373 "UnrecognizedVirtualPixelMethod",argv[i]);
1374 break;
1375 }
1376 if (LocaleCompare("visual",option+1) == 0)
1377 {
1378 resource_info.visual_type=(char *) NULL;
1379 if (*option == '+')
1380 break;
1381 i++;
cristybb503372010-05-27 20:51:26 +00001382 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001383 ThrowAnimateException(OptionError,"MissingArgument",option);
1384 resource_info.visual_type=argv[i];
1385 break;
1386 }
1387 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1388 }
1389 case 'w':
1390 {
1391 if (LocaleCompare("window",option+1) == 0)
1392 {
1393 resource_info.window_id=(char *) NULL;
1394 if (*option == '+')
1395 break;
1396 i++;
cristybb503372010-05-27 20:51:26 +00001397 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001398 ThrowAnimateException(OptionError,"MissingArgument",option);
1399 resource_info.window_id=argv[i];
1400 break;
1401 }
1402 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1403 }
1404 case '?':
1405 break;
1406 default:
1407 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1408 }
cristy042ee782011-04-22 18:48:30 +00001409 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
1410 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
cristy3ed852e2009-09-05 21:47:34 +00001411 if (fire != MagickFalse)
1412 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
1413 }
cristy259a33e2009-11-06 15:22:25 +00001414 i--;
cristy3ed852e2009-09-05 21:47:34 +00001415 if (k != 0)
1416 ThrowAnimateException(OptionError,"UnbalancedParenthesis",argv[i]);
1417 if (image == (Image *) NULL)
1418 ThrowAnimateException(OptionError,"MissingAnImageFilename",argv[argc-1])
1419 FinalizeImageSettings(image_info,image,MagickTrue);
cristy94f20072009-09-12 02:12:36 +00001420 if (image == (Image *) NULL)
1421 ThrowAnimateException(OptionError,"MissingAnImageFilename",argv[argc-1])
cristy3ed852e2009-09-05 21:47:34 +00001422 if (resource_info.window_id != (char *) NULL)
1423 {
cristy051718b2011-08-28 22:49:25 +00001424 XAnimateBackgroundImage(display,&resource_info,image,exception);
cristy3ed852e2009-09-05 21:47:34 +00001425 status&=MagickTrue;
1426 }
1427 else
1428 {
1429 Image
1430 *animate_image;
1431
1432 /*
1433 Animate image to X server.
1434 */
cristy051718b2011-08-28 22:49:25 +00001435 animate_image=XAnimateImages(display,&resource_info,argv,argc,image,
1436 exception);
cristy3ed852e2009-09-05 21:47:34 +00001437 while (animate_image != (Image *) NULL)
1438 {
1439 image=animate_image;
cristy051718b2011-08-28 22:49:25 +00001440 animate_image=XAnimateImages(display,&resource_info,argv,argc,image,
1441 exception);
cristy3ed852e2009-09-05 21:47:34 +00001442 if (animate_image != image)
1443 image=DestroyImageList(image);
1444 }
1445 }
1446 DestroyAnimate();
1447 return(status != 0 ? MagickTrue : MagickFalse);
1448#else
dirkd06c8892016-09-18 19:38:08 +02001449 wand_unreferenced(argc);
1450 wand_unreferenced(argv);
1451 wand_unreferenced(metadata);
cristy3ed852e2009-09-05 21:47:34 +00001452 (void) ThrowMagickException(exception,GetMagickModule(),MissingDelegateError,
anthonye5b39652012-04-21 05:37:29 +00001453 "DelegateLibrarySupportNotBuiltIn","'%s' (X11)",image_info->filename);
cristy3ed852e2009-09-05 21:47:34 +00001454 return(AnimateUsage());
1455#endif
1456}