blob: 0294924487c8d68b2b25b49a66e36eb7d377bccd [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% %
cristyb56bb242014-11-25 17:12:48 +000020% Copyright 1999-2015 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(
212 "-borderwidth, -font, -foreground, -iconGeometry, -iconic, -name,\n");
213 (void) printf("-mattecolor, -shared-memory, or -title.\n");
214 (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);
306 assert(image_info->signature == MagickSignature);
307 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);
cristy3ed852e2009-09-05 21:47:34 +0000317 return(MagickFalse);
318 }
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);
cristy288a3532012-08-28 00:19:44 +0000464 type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000465 if (type < 0)
cristyb15b06c2012-08-28 11:36:48 +0000466 ThrowAnimateException(OptionError,"UnrecognizedAlphaChannelOption",
cristy3ed852e2009-09-05 21:47:34 +0000467 argv[i]);
468 break;
469 }
470 if (LocaleCompare("authenticate",option+1) == 0)
471 {
472 if (*option == '+')
473 break;
474 i++;
cristybb503372010-05-27 20:51:26 +0000475 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000476 ThrowAnimateException(OptionError,"MissingArgument",option);
477 break;
478 }
479 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
480 }
481 case 'b':
482 {
483 if (LocaleCompare("backdrop",option+1) == 0)
484 {
485 resource_info.backdrop=(*option == '-') ? MagickTrue : MagickFalse;
486 break;
487 }
488 if (LocaleCompare("background",option+1) == 0)
489 {
490 if (*option == '+')
491 break;
492 i++;
cristybb503372010-05-27 20:51:26 +0000493 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000494 ThrowAnimateException(OptionError,"MissingArgument",option);
495 resource_info.background_color=argv[i];
496 break;
497 }
498 if (LocaleCompare("bordercolor",option+1) == 0)
499 {
500 if (*option == '+')
501 break;
502 i++;
cristybb503372010-05-27 20:51:26 +0000503 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000504 ThrowAnimateException(OptionError,"MissingArgument",option);
505 resource_info.border_color=argv[i];
506 break;
507 }
508 if (LocaleCompare("borderwidth",option+1) == 0)
509 {
510 resource_info.border_width=0;
511 if (*option == '+')
512 break;
513 i++;
cristybb503372010-05-27 20:51:26 +0000514 if ((i == (ssize_t) argc) || (IsGeometry(argv[i]) == MagickFalse))
cristy3ed852e2009-09-05 21:47:34 +0000515 ThrowAnimateException(OptionError,"MissingArgument",option);
cristye27293e2009-12-18 02:53:20 +0000516 resource_info.border_width=(unsigned int)
517 StringToUnsignedLong(argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000518 break;
519 }
520 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
521 }
522 case 'c':
523 {
524 if (LocaleCompare("cache",option+1) == 0)
525 {
526 if (*option == '+')
527 break;
528 i++;
cristybb503372010-05-27 20:51:26 +0000529 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000530 ThrowAnimateException(OptionError,"MissingArgument",option);
531 if (IsGeometry(argv[i]) == MagickFalse)
532 ThrowAnimateInvalidArgumentException(option,argv[i]);
533 break;
534 }
535 if (LocaleCompare("channel",option+1) == 0)
536 {
cristybb503372010-05-27 20:51:26 +0000537 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000538 channel;
539
540 if (*option == '+')
541 break;
542 i++;
cristye81f5522014-05-07 01:25:59 +0000543 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000544 ThrowAnimateException(OptionError,"MissingArgument",option);
545 channel=ParseChannelOption(argv[i]);
546 if (channel < 0)
547 ThrowAnimateException(OptionError,"UnrecognizedChannelType",
548 argv[i]);
549 break;
550 }
551 if (LocaleCompare("clone",option+1) == 0)
552 {
553 Image
554 *clone_images;
555
556 clone_images=image;
557 if (k != 0)
558 clone_images=image_stack[k-1].image;
559 if (clone_images == (Image *) NULL)
anthony8226e722012-04-05 14:25:46 +0000560 ThrowAnimateException(ImageError,"UnableToCloneImage",option);
cristy3ed852e2009-09-05 21:47:34 +0000561 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
562 if (*option == '+')
563 clone_images=CloneImages(clone_images,"-1",exception);
564 else
565 {
566 i++;
cristye81f5522014-05-07 01:25:59 +0000567 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000568 ThrowAnimateException(OptionError,"MissingArgument",option);
569 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
570 ThrowAnimateInvalidArgumentException(option,argv[i]);
571 clone_images=CloneImages(clone_images,argv[i],exception);
572 }
573 if (clone_images == (Image *) NULL)
574 ThrowAnimateException(OptionError,"NoSuchImage",option);
575 AppendImageStack(clone_images);
576 break;
577 }
578 if (LocaleCompare("coalesce",option+1) == 0)
579 break;
580 if (LocaleCompare("colormap",option+1) == 0)
581 {
582 resource_info.colormap=PrivateColormap;
583 if (*option == '+')
584 break;
585 i++;
cristybb503372010-05-27 20:51:26 +0000586 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000587 ThrowAnimateException(OptionError,"MissingArgument",option);
588 resource_info.colormap=UndefinedColormap;
589 if (LocaleCompare("private",argv[i]) == 0)
590 resource_info.colormap=PrivateColormap;
591 if (LocaleCompare("shared",argv[i]) == 0)
592 resource_info.colormap=SharedColormap;
593 if (resource_info.colormap == UndefinedColormap)
594 ThrowAnimateException(OptionError,"UnrecognizedColormapType",
595 argv[i]);
596 break;
597 }
598 if (LocaleCompare("colors",option+1) == 0)
599 {
600 quantize_info->number_colors=0;
601 if (*option == '+')
602 break;
603 i++;
cristybb503372010-05-27 20:51:26 +0000604 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000605 ThrowAnimateException(OptionError,"MissingArgument",option);
606 if (IsGeometry(argv[i]) == MagickFalse)
607 ThrowAnimateInvalidArgumentException(option,argv[i]);
cristye27293e2009-12-18 02:53:20 +0000608 quantize_info->number_colors=StringToUnsignedLong(argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000609 break;
610 }
611 if (LocaleCompare("colorspace",option+1) == 0)
612 {
cristybb503372010-05-27 20:51:26 +0000613 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000614 colorspace;
615
616 if (*option == '+')
617 break;
618 i++;
cristybb503372010-05-27 20:51:26 +0000619 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000620 ThrowAnimateException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000621 colorspace=ParseCommandOption(MagickColorspaceOptions,
cristy3ed852e2009-09-05 21:47:34 +0000622 MagickFalse,argv[i]);
623 if (colorspace < 0)
624 ThrowAnimateException(OptionError,"UnrecognizedColorspace",
625 argv[i]);
626 break;
627 }
cristy22879752009-10-25 23:55:40 +0000628 if (LocaleCompare("concurrent",option+1) == 0)
629 break;
cristy3ed852e2009-09-05 21:47:34 +0000630 if (LocaleCompare("crop",option+1) == 0)
631 {
632 if (*option == '+')
633 break;
634 i++;
cristybb503372010-05-27 20:51:26 +0000635 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000636 ThrowAnimateException(OptionError,"MissingArgument",option);
637 if (IsGeometry(argv[i]) == MagickFalse)
638 ThrowAnimateInvalidArgumentException(option,argv[i]);
639 break;
640 }
641 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
642 }
643 case 'd':
644 {
645 if (LocaleCompare("debug",option+1) == 0)
646 {
cristybb503372010-05-27 20:51:26 +0000647 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000648 event;
649
650 if (*option == '+')
651 break;
652 i++;
cristybb503372010-05-27 20:51:26 +0000653 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000654 ThrowAnimateException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000655 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000656 if (event < 0)
657 ThrowAnimateException(OptionError,"UnrecognizedEventType",
658 argv[i]);
659 (void) SetLogEventMask(argv[i]);
660 break;
661 }
662 if (LocaleCompare("decipher",option+1) == 0)
663 {
664 if (*option == '+')
665 break;
666 i++;
cristye81f5522014-05-07 01:25:59 +0000667 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000668 ThrowAnimateException(OptionError,"MissingArgument",option);
669 break;
670 }
671 if (LocaleCompare("define",option+1) == 0)
672 {
673 i++;
cristybb503372010-05-27 20:51:26 +0000674 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000675 ThrowAnimateException(OptionError,"MissingArgument",option);
676 if (*option == '+')
677 {
678 const char
679 *define;
680
681 define=GetImageOption(image_info,argv[i]);
682 if (define == (const char *) NULL)
683 ThrowAnimateException(OptionError,"NoSuchOption",argv[i]);
684 break;
685 }
686 break;
687 }
688 if (LocaleCompare("delay",option+1) == 0)
689 {
690 if (*option == '+')
691 break;
692 i++;
cristybb503372010-05-27 20:51:26 +0000693 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000694 ThrowAnimateException(OptionError,"MissingArgument",option);
695 if (IsGeometry(argv[i]) == MagickFalse)
696 ThrowAnimateInvalidArgumentException(option,argv[i]);
697 break;
698 }
699 if (LocaleCompare("density",option+1) == 0)
700 {
701 if (*option == '+')
702 break;
703 i++;
cristybb503372010-05-27 20:51:26 +0000704 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000705 ThrowAnimateException(OptionError,"MissingArgument",option);
706 if (IsGeometry(argv[i]) == MagickFalse)
707 ThrowAnimateInvalidArgumentException(option,argv[i]);
708 break;
709 }
710 if (LocaleCompare("depth",option+1) == 0)
711 {
712 if (*option == '+')
713 break;
714 i++;
cristybb503372010-05-27 20:51:26 +0000715 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000716 ThrowAnimateException(OptionError,"MissingArgument",option);
717 if (IsGeometry(argv[i]) == MagickFalse)
718 ThrowAnimateInvalidArgumentException(option,argv[i]);
719 break;
720 }
721 if (LocaleCompare("display",option+1) == 0)
722 {
723 if (*option == '+')
724 break;
725 i++;
cristybb503372010-05-27 20:51:26 +0000726 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000727 ThrowAnimateException(OptionError,"MissingArgument",option);
728 break;
729 }
730 if (LocaleCompare("dispose",option+1) == 0)
731 {
cristybb503372010-05-27 20:51:26 +0000732 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000733 dispose;
734
735 if (*option == '+')
736 break;
737 i++;
cristybb503372010-05-27 20:51:26 +0000738 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000739 ThrowAnimateException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000740 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000741 if (dispose < 0)
742 ThrowAnimateException(OptionError,"UnrecognizedDisposeMethod",
743 argv[i]);
744 break;
745 }
746 if (LocaleCompare("dither",option+1) == 0)
747 {
cristybb503372010-05-27 20:51:26 +0000748 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000749 method;
750
cristycbda6112012-05-27 20:57:16 +0000751 quantize_info->dither_method=NoDitherMethod;
cristy3ed852e2009-09-05 21:47:34 +0000752 if (*option == '+')
753 break;
754 i++;
cristybb503372010-05-27 20:51:26 +0000755 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000756 ThrowAnimateException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000757 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000758 if (method < 0)
759 ThrowAnimateException(OptionError,"UnrecognizedDitherMethod",
760 argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000761 quantize_info->dither_method=(DitherMethod) method;
762 break;
763 }
cristy22879752009-10-25 23:55:40 +0000764 if (LocaleCompare("duration",option+1) == 0)
765 {
766 if (*option == '+')
767 break;
768 i++;
cristye81f5522014-05-07 01:25:59 +0000769 if (i == (ssize_t) argc)
cristy22879752009-10-25 23:55:40 +0000770 ThrowAnimateException(OptionError,"MissingArgument",option);
771 if (IsGeometry(argv[i]) == MagickFalse)
772 ThrowAnimateInvalidArgumentException(option,argv[i]);
773 break;
774 }
cristy3ed852e2009-09-05 21:47:34 +0000775 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
776 }
777 case 'e':
778 {
779 if (LocaleCompare("extract",option+1) == 0)
780 {
781 if (*option == '+')
782 break;
783 i++;
cristybb503372010-05-27 20:51:26 +0000784 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000785 ThrowAnimateException(OptionError,"MissingArgument",option);
786 if (IsGeometry(argv[i]) == MagickFalse)
787 ThrowAnimateInvalidArgumentException(option,argv[i]);
788 break;
789 }
790 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
791 }
792 case 'f':
793 {
794 if (LocaleCompare("filter",option+1) == 0)
795 {
cristybb503372010-05-27 20:51:26 +0000796 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000797 filter;
798
799 if (*option == '+')
800 break;
801 i++;
cristye81f5522014-05-07 01:25:59 +0000802 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000803 ThrowAnimateException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000804 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000805 if (filter < 0)
806 ThrowAnimateException(OptionError,"UnrecognizedImageFilter",
807 argv[i]);
808 break;
809 }
810 if (LocaleCompare("flatten",option+1) == 0)
811 break;
812 if (LocaleCompare("font",option+1) == 0)
813 {
814 if (*option == '+')
815 break;
816 i++;
cristybb503372010-05-27 20:51:26 +0000817 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000818 ThrowAnimateException(OptionError,"MissingArgument",option);
819 resource_info.font=XGetResourceClass(resource_database,
820 GetClientName(),"font",argv[i]);
821 break;
822 }
823 if (LocaleCompare("foreground",option+1) == 0)
824 {
825 if (*option == '+')
826 break;
827 i++;
cristybb503372010-05-27 20:51:26 +0000828 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000829 ThrowAnimateException(OptionError,"MissingArgument",option);
830 resource_info.foreground_color=argv[i];
831 break;
832 }
833 if (LocaleCompare("format",option+1) == 0)
834 {
835 if (*option == '+')
836 break;
837 i++;
cristye81f5522014-05-07 01:25:59 +0000838 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000839 ThrowAnimateException(OptionError,"MissingArgument",option);
840 break;
841 }
842 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
843 }
844 case 'g':
845 {
846 if (LocaleCompare("gamma",option+1) == 0)
847 {
848 i++;
cristybb503372010-05-27 20:51:26 +0000849 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000850 ThrowAnimateException(OptionError,"MissingArgument",option);
851 if (IsGeometry(argv[i]) == MagickFalse)
852 ThrowAnimateInvalidArgumentException(option,argv[i]);
853 break;
854 }
855 if (LocaleCompare("geometry",option+1) == 0)
856 {
857 resource_info.image_geometry=(char *) NULL;
858 if (*option == '+')
859 break;
860 i++;
cristybb503372010-05-27 20:51:26 +0000861 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000862 ThrowAnimateException(OptionError,"MissingArgument",option);
863 if (IsGeometry(argv[i]) == MagickFalse)
864 ThrowAnimateInvalidArgumentException(option,argv[i]);
865 resource_info.image_geometry=ConstantString(argv[i]);
866 break;
867 }
868 if (LocaleCompare("gravity",option+1) == 0)
869 {
cristybb503372010-05-27 20:51:26 +0000870 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000871 gravity;
872
873 if (*option == '+')
874 break;
875 i++;
cristye81f5522014-05-07 01:25:59 +0000876 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000877 ThrowAnimateException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000878 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +0000879 argv[i]);
880 if (gravity < 0)
881 ThrowAnimateException(OptionError,"UnrecognizedGravityType",
882 argv[i]);
883 break;
884 }
885 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
886 }
887 case 'h':
888 {
889 if ((LocaleCompare("help",option+1) == 0) ||
890 (LocaleCompare("-help",option+1) == 0))
891 break;
892 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
893 }
894 case 'i':
895 {
896 if (LocaleCompare("iconGeometry",option+1) == 0)
897 {
898 resource_info.icon_geometry=(char *) NULL;
899 if (*option == '+')
900 break;
901 i++;
cristybb503372010-05-27 20:51:26 +0000902 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000903 ThrowAnimateException(OptionError,"MissingArgument",option);
904 if (IsGeometry(argv[i]) == MagickFalse)
905 ThrowAnimateInvalidArgumentException(option,argv[i]);
906 resource_info.icon_geometry=argv[i];
907 break;
908 }
909 if (LocaleCompare("iconic",option+1) == 0)
910 {
911 resource_info.iconic=(*option == '-') ? MagickTrue : MagickFalse;
912 break;
913 }
914 if (LocaleCompare("identify",option+1) == 0)
915 break;
916 if (LocaleCompare("immutable",option+1) == 0)
917 {
918 resource_info.immutable=(*option == '-') ? MagickTrue : MagickFalse;
919 break;
920 }
921 if (LocaleCompare("interlace",option+1) == 0)
922 {
cristybb503372010-05-27 20:51:26 +0000923 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000924 interlace;
925
926 if (*option == '+')
927 break;
928 i++;
cristybb503372010-05-27 20:51:26 +0000929 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000930 ThrowAnimateException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000931 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +0000932 argv[i]);
933 if (interlace < 0)
934 ThrowAnimateException(OptionError,"UnrecognizedInterlaceType",
935 argv[i]);
936 break;
937 }
938 if (LocaleCompare("interpolate",option+1) == 0)
939 {
cristybb503372010-05-27 20:51:26 +0000940 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000941 interpolate;
942
943 if (*option == '+')
944 break;
945 i++;
cristybb503372010-05-27 20:51:26 +0000946 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000947 ThrowAnimateException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000948 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +0000949 argv[i]);
950 if (interpolate < 0)
951 ThrowAnimateException(OptionError,"UnrecognizedInterpolateMethod",
952 argv[i]);
953 break;
954 }
955 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
956 }
957 case 'l':
958 {
959 if (LocaleCompare("label",option+1) == 0)
960 {
961 if (*option == '+')
962 break;
963 i++;
cristybb503372010-05-27 20:51:26 +0000964 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000965 ThrowAnimateException(OptionError,"MissingArgument",option);
966 break;
967 }
968 if (LocaleCompare("limit",option+1) == 0)
969 {
970 char
971 *p;
972
973 double
974 value;
975
cristybb503372010-05-27 20:51:26 +0000976 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000977 resource;
978
979 if (*option == '+')
980 break;
981 i++;
cristybb503372010-05-27 20:51:26 +0000982 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000983 ThrowAnimateException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000984 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +0000985 argv[i]);
986 if (resource < 0)
987 ThrowAnimateException(OptionError,"UnrecognizedResourceType",
988 argv[i]);
989 i++;
cristybb503372010-05-27 20:51:26 +0000990 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000991 ThrowAnimateException(OptionError,"MissingArgument",option);
cristydbdd0e32011-11-04 23:29:40 +0000992 value=StringToDouble(argv[i],&p);
cristyda16f162011-02-19 23:52:17 +0000993 (void) value;
cristy3ed852e2009-09-05 21:47:34 +0000994 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
995 ThrowAnimateInvalidArgumentException(option,argv[i]);
996 break;
997 }
998 if (LocaleCompare("list",option+1) == 0)
999 {
cristybb503372010-05-27 20:51:26 +00001000 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00001001 list;
1002
1003 if (*option == '+')
1004 break;
1005 i++;
cristybb503372010-05-27 20:51:26 +00001006 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001007 ThrowAnimateException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00001008 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00001009 if (list < 0)
1010 ThrowAnimateException(OptionError,"UnrecognizedListType",argv[i]);
cristyaeb2cbc2010-05-07 13:28:58 +00001011 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
cristy3ed852e2009-09-05 21:47:34 +00001012 argv+j,exception);
1013 DestroyAnimate();
cristy32ce2392014-09-24 19:08:53 +00001014 return(status == 0 ? MagickTrue : MagickFalse);
cristy3ed852e2009-09-05 21:47:34 +00001015 }
1016 if (LocaleCompare("log",option+1) == 0)
1017 {
1018 if (*option == '+')
1019 break;
1020 i++;
cristybb503372010-05-27 20:51:26 +00001021 if ((i == (ssize_t) argc) ||
cristy3ed852e2009-09-05 21:47:34 +00001022 (strchr(argv[i],'%') == (char *) NULL))
1023 ThrowAnimateException(OptionError,"MissingArgument",option);
1024 break;
1025 }
1026 if (LocaleCompare("loop",option+1) == 0)
1027 {
1028 if (*option == '+')
1029 break;
1030 i++;
cristye81f5522014-05-07 01:25:59 +00001031 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001032 ThrowAnimateException(OptionError,"MissingArgument",option);
1033 if (IsGeometry(argv[i]) == MagickFalse)
1034 ThrowAnimateInvalidArgumentException(option,argv[i]);
1035 break;
1036 }
1037 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1038 }
1039 case 'm':
1040 {
1041 if (LocaleCompare("map",option+1) == 0)
1042 {
1043 resource_info.map_type=(char *) NULL;
1044 if (*option == '+')
1045 break;
1046 (void) CopyMagickString(argv[i]+1,"san",MaxTextExtent);
1047 i++;
cristybb503372010-05-27 20:51:26 +00001048 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001049 ThrowAnimateException(OptionError,"MissingArgument",option);
1050 resource_info.map_type=argv[i];
1051 break;
1052 }
1053 if (LocaleCompare("matte",option+1) == 0)
1054 break;
1055 if (LocaleCompare("mattecolor",option+1) == 0)
1056 {
1057 if (*option == '+')
1058 break;
1059 i++;
cristybb503372010-05-27 20:51:26 +00001060 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001061 ThrowAnimateException(OptionError,"MissingArgument",option);
1062 resource_info.matte_color=argv[i];
1063 break;
1064 }
1065 if (LocaleCompare("monitor",option+1) == 0)
1066 break;
1067 if (LocaleCompare("monochrome",option+1) == 0)
1068 {
1069 if (*option == '+')
1070 break;
1071 quantize_info->number_colors=2;
1072 quantize_info->colorspace=GRAYColorspace;
1073 break;
1074 }
1075 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1076 }
1077 case 'n':
1078 {
1079 if (LocaleCompare("name",option+1) == 0)
1080 {
1081 resource_info.name=(char *) NULL;
1082 if (*option == '+')
1083 break;
1084 i++;
cristybb503372010-05-27 20:51:26 +00001085 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001086 ThrowAnimateException(OptionError,"MissingArgument",option);
1087 resource_info.name=ConstantString(argv[i]);
1088 break;
1089 }
1090 if (LocaleCompare("noop",option+1) == 0)
1091 break;
1092 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1093 }
1094 case 'p':
1095 {
1096 if (LocaleCompare("pause",option+1) == 0)
1097 {
1098 resource_info.pause=0;
1099 if (*option == '+')
1100 break;
1101 i++;
cristybb503372010-05-27 20:51:26 +00001102 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001103 ThrowAnimateException(OptionError,"MissingArgument",option);
1104 if (IsGeometry(argv[i]) == MagickFalse)
1105 ThrowAnimateInvalidArgumentException(option,argv[i]);
cristye27293e2009-12-18 02:53:20 +00001106 resource_info.pause=(unsigned int) StringToUnsignedLong(argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00001107 break;
1108 }
1109 if (LocaleCompare("page",option+1) == 0)
1110 {
1111 if (*option == '+')
1112 break;
1113 i++;
cristybb503372010-05-27 20:51:26 +00001114 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001115 ThrowAnimateException(OptionError,"MissingArgument",option);
1116 break;
1117 }
1118 if (LocaleCompare("profile",option+1) == 0)
1119 {
1120 i++;
cristybb503372010-05-27 20:51:26 +00001121 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001122 ThrowAnimateException(OptionError,"MissingArgument",option);
1123 break;
1124 }
1125 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1126 }
1127 case 'q':
1128 {
1129 if (LocaleCompare("quantize",option+1) == 0)
1130 {
cristybb503372010-05-27 20:51:26 +00001131 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00001132 colorspace;
1133
1134 if (*option == '+')
1135 break;
1136 i++;
cristye81f5522014-05-07 01:25:59 +00001137 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001138 ThrowAnimateException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00001139 colorspace=ParseCommandOption(MagickColorspaceOptions,
cristy3ed852e2009-09-05 21:47:34 +00001140 MagickFalse,argv[i]);
1141 if (colorspace < 0)
1142 ThrowAnimateException(OptionError,"UnrecognizedColorspace",
1143 argv[i]);
1144 break;
1145 }
1146 if (LocaleCompare("quiet",option+1) == 0)
1147 break;
1148 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1149 }
1150 case 'r':
1151 {
1152 if (LocaleCompare("regard-warnings",option+1) == 0)
1153 break;
1154 if (LocaleCompare("remote",option+1) == 0)
1155 {
1156 i++;
cristybb503372010-05-27 20:51:26 +00001157 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001158 ThrowAnimateException(OptionError,"MissingArgument",option);
1159 if (XRemoteCommand(display,resource_info.window_id,argv[i]) != 0)
1160 return(MagickFalse);
1161 i--;
1162 break;
1163 }
1164 if (LocaleCompare("repage",option+1) == 0)
1165 {
1166 if (*option == '+')
1167 break;
1168 i++;
cristybb503372010-05-27 20:51:26 +00001169 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001170 ThrowAnimateException(OptionError,"MissingArgument",option);
1171 if (IsGeometry(argv[i]) == MagickFalse)
1172 ThrowAnimateInvalidArgumentException(option,argv[i]);
1173 break;
1174 }
1175 if (LocaleCompare("resample",option+1) == 0)
1176 {
1177 if (*option == '+')
1178 break;
1179 i++;
cristye81f5522014-05-07 01:25:59 +00001180 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001181 ThrowAnimateException(OptionError,"MissingArgument",option);
1182 if (IsGeometry(argv[i]) == MagickFalse)
1183 ThrowAnimateInvalidArgumentException(option,argv[i]);
1184 break;
1185 }
1186 if (LocaleCompare("resize",option+1) == 0)
1187 {
1188 if (*option == '+')
1189 break;
1190 i++;
cristybb503372010-05-27 20:51:26 +00001191 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001192 ThrowAnimateException(OptionError,"MissingArgument",option);
1193 if (IsGeometry(argv[i]) == MagickFalse)
1194 ThrowAnimateInvalidArgumentException(option,argv[i]);
1195 break;
1196 }
1197 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
1198 {
1199 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
1200 break;
1201 }
1202 if (LocaleCompare("rotate",option+1) == 0)
1203 {
1204 i++;
cristybb503372010-05-27 20:51:26 +00001205 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001206 ThrowAnimateException(OptionError,"MissingArgument",option);
1207 if (IsGeometry(argv[i]) == MagickFalse)
1208 ThrowAnimateInvalidArgumentException(option,argv[i]);
1209 break;
1210 }
1211 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1212 }
1213 case 's':
1214 {
1215 if (LocaleCompare("sampling-factor",option+1) == 0)
1216 {
1217 if (*option == '+')
1218 break;
1219 i++;
cristybb503372010-05-27 20:51:26 +00001220 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001221 ThrowAnimateException(OptionError,"MissingArgument",option);
1222 if (IsGeometry(argv[i]) == MagickFalse)
1223 ThrowAnimateInvalidArgumentException(option,argv[i]);
1224 break;
1225 }
1226 if (LocaleCompare("seed",option+1) == 0)
1227 {
1228 if (*option == '+')
1229 break;
1230 i++;
cristye81f5522014-05-07 01:25:59 +00001231 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001232 ThrowAnimateException(OptionError,"MissingArgument",option);
1233 if (IsGeometry(argv[i]) == MagickFalse)
1234 ThrowAnimateInvalidArgumentException(option,argv[i]);
1235 break;
1236 }
1237 if (LocaleCompare("scenes",option+1) == 0) /* deprecated */
1238 {
1239 if (*option == '+')
1240 break;
1241 i++;
cristybb503372010-05-27 20:51:26 +00001242 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001243 ThrowAnimateException(OptionError,"MissingArgument",option);
1244 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
1245 ThrowAnimateInvalidArgumentException(option,argv[i]);
1246 break;
1247 }
1248 if (LocaleCompare("set",option+1) == 0)
1249 {
1250 i++;
cristybb503372010-05-27 20:51:26 +00001251 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001252 ThrowAnimateException(OptionError,"MissingArgument",option);
1253 if (*option == '+')
1254 break;
1255 i++;
cristybb503372010-05-27 20:51:26 +00001256 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001257 ThrowAnimateException(OptionError,"MissingArgument",option);
1258 break;
1259 }
1260 if (LocaleCompare("shared-memory",option+1) == 0)
1261 {
1262 resource_info.use_shared_memory=(*option == '-') ? MagickTrue :
1263 MagickFalse;
1264 break;
1265 }
1266 if (LocaleCompare("size",option+1) == 0)
1267 {
1268 if (*option == '+')
1269 break;
1270 i++;
cristybb503372010-05-27 20:51:26 +00001271 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001272 ThrowAnimateException(OptionError,"MissingArgument",option);
1273 if (IsGeometry(argv[i]) == MagickFalse)
1274 ThrowAnimateInvalidArgumentException(option,argv[i]);
1275 break;
1276 }
1277 if (LocaleCompare("strip",option+1) == 0)
1278 break;
1279 if (LocaleCompare("support",option+1) == 0)
1280 {
1281 i++; /* deprecated */
1282 break;
1283 }
1284 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1285 }
1286 case 't':
1287 {
1288 if (LocaleCompare("text-font",option+1) == 0)
1289 {
1290 resource_info.text_font=(char *) NULL;
1291 if (*option == '+')
1292 break;
1293 i++;
cristybb503372010-05-27 20:51:26 +00001294 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001295 ThrowAnimateException(OptionError,"MissingArgument",option);
1296 resource_info.text_font=XGetResourceClass(resource_database,
1297 GetClientName(),"font",argv[i]);
1298 break;
1299 }
1300 if (LocaleCompare("thumbnail",option+1) == 0)
1301 {
1302 if (*option == '+')
1303 break;
1304 i++;
cristybb503372010-05-27 20:51:26 +00001305 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001306 ThrowAnimateException(OptionError,"MissingArgument",option);
1307 if (IsGeometry(argv[i]) == MagickFalse)
1308 ThrowAnimateInvalidArgumentException(option,argv[i]);
1309 break;
1310 }
1311 if (LocaleCompare("title",option+1) == 0)
1312 {
1313 resource_info.title=(char *) NULL;
1314 if (*option == '+')
1315 break;
1316 i++;
cristybb503372010-05-27 20:51:26 +00001317 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001318 ThrowAnimateException(OptionError,"MissingArgument",option);
1319 resource_info.title=argv[i];
1320 break;
1321 }
1322 if (LocaleCompare("transparent-color",option+1) == 0)
1323 {
1324 if (*option == '+')
1325 break;
1326 i++;
cristye81f5522014-05-07 01:25:59 +00001327 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001328 ThrowAnimateException(OptionError,"MissingArgument",option);
1329 break;
1330 }
1331 if (LocaleCompare("treedepth",option+1) == 0)
1332 {
1333 quantize_info->tree_depth=0;
1334 if (*option == '+')
1335 break;
1336 i++;
cristybb503372010-05-27 20:51:26 +00001337 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001338 ThrowAnimateException(OptionError,"MissingArgument",option);
1339 if (IsGeometry(argv[i]) == MagickFalse)
1340 ThrowAnimateInvalidArgumentException(option,argv[i]);
cristye27293e2009-12-18 02:53:20 +00001341 quantize_info->tree_depth=StringToUnsignedLong(argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00001342 break;
1343 }
1344 if (LocaleCompare("trim",option+1) == 0)
1345 break;
1346 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1347 }
1348 case 'v':
1349 {
1350 if (LocaleCompare("verbose",option+1) == 0)
1351 break;
1352 if ((LocaleCompare("version",option+1) == 0) ||
1353 (LocaleCompare("-version",option+1) == 0))
1354 {
cristy4f7a6132012-12-23 00:35:19 +00001355 ListMagickVersion(stdout);
cristy3ed852e2009-09-05 21:47:34 +00001356 break;
1357 }
1358 if (LocaleCompare("virtual-pixel",option+1) == 0)
1359 {
cristybb503372010-05-27 20:51:26 +00001360 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00001361 method;
1362
1363 if (*option == '+')
1364 break;
1365 i++;
cristybb503372010-05-27 20:51:26 +00001366 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001367 ThrowAnimateException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00001368 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00001369 argv[i]);
1370 if (method < 0)
1371 ThrowAnimateException(OptionError,
1372 "UnrecognizedVirtualPixelMethod",argv[i]);
1373 break;
1374 }
1375 if (LocaleCompare("visual",option+1) == 0)
1376 {
1377 resource_info.visual_type=(char *) NULL;
1378 if (*option == '+')
1379 break;
1380 i++;
cristybb503372010-05-27 20:51:26 +00001381 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001382 ThrowAnimateException(OptionError,"MissingArgument",option);
1383 resource_info.visual_type=argv[i];
1384 break;
1385 }
1386 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1387 }
1388 case 'w':
1389 {
1390 if (LocaleCompare("window",option+1) == 0)
1391 {
1392 resource_info.window_id=(char *) NULL;
1393 if (*option == '+')
1394 break;
1395 i++;
cristybb503372010-05-27 20:51:26 +00001396 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001397 ThrowAnimateException(OptionError,"MissingArgument",option);
1398 resource_info.window_id=argv[i];
1399 break;
1400 }
1401 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1402 }
1403 case '?':
1404 break;
1405 default:
1406 ThrowAnimateException(OptionError,"UnrecognizedOption",option);
1407 }
cristy042ee782011-04-22 18:48:30 +00001408 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
1409 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
cristy3ed852e2009-09-05 21:47:34 +00001410 if (fire != MagickFalse)
1411 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
1412 }
cristy259a33e2009-11-06 15:22:25 +00001413 i--;
cristy3ed852e2009-09-05 21:47:34 +00001414 if (k != 0)
1415 ThrowAnimateException(OptionError,"UnbalancedParenthesis",argv[i]);
1416 if (image == (Image *) NULL)
1417 ThrowAnimateException(OptionError,"MissingAnImageFilename",argv[argc-1])
1418 FinalizeImageSettings(image_info,image,MagickTrue);
cristy94f20072009-09-12 02:12:36 +00001419 if (image == (Image *) NULL)
1420 ThrowAnimateException(OptionError,"MissingAnImageFilename",argv[argc-1])
cristy3ed852e2009-09-05 21:47:34 +00001421 if (resource_info.window_id != (char *) NULL)
1422 {
cristy051718b2011-08-28 22:49:25 +00001423 XAnimateBackgroundImage(display,&resource_info,image,exception);
cristy3ed852e2009-09-05 21:47:34 +00001424 status&=MagickTrue;
1425 }
1426 else
1427 {
1428 Image
1429 *animate_image;
1430
1431 /*
1432 Animate image to X server.
1433 */
cristy051718b2011-08-28 22:49:25 +00001434 animate_image=XAnimateImages(display,&resource_info,argv,argc,image,
1435 exception);
cristy3ed852e2009-09-05 21:47:34 +00001436 while (animate_image != (Image *) NULL)
1437 {
1438 image=animate_image;
cristy051718b2011-08-28 22:49:25 +00001439 animate_image=XAnimateImages(display,&resource_info,argv,argc,image,
1440 exception);
cristy3ed852e2009-09-05 21:47:34 +00001441 if (animate_image != image)
1442 image=DestroyImageList(image);
1443 }
1444 }
1445 DestroyAnimate();
1446 return(status != 0 ? MagickTrue : MagickFalse);
1447#else
1448 (void) argc;
1449 (void) argv;
1450 (void) ThrowMagickException(exception,GetMagickModule(),MissingDelegateError,
anthonye5b39652012-04-21 05:37:29 +00001451 "DelegateLibrarySupportNotBuiltIn","'%s' (X11)",image_info->filename);
cristy3ed852e2009-09-05 21:47:34 +00001452 return(AnimateUsage());
1453#endif
1454}