cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1 | /* |
| 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 % |
cristy | de984cd | 2013-12-01 14:49:27 +0000 | [diff] [blame] | 16 | % Cristy % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 17 | % July 1992 % |
| 18 | % % |
| 19 | % % |
cristy | b56bb24 | 2014-11-25 17:12:48 +0000 | [diff] [blame] | 20 | % Copyright 1999-2015 ImageMagick Studio LLC, a non-profit organization % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 21 | % 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 | */ |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 43 | #include "MagickWand/studio.h" |
| 44 | #include "MagickWand/MagickWand.h" |
| 45 | #include "MagickWand/mogrify-private.h" |
| 46 | #include "MagickCore/animate-private.h" |
| 47 | #include "MagickCore/string-private.h" |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 48 | |
| 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 | |
| 93 | static 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 | { |
cristy | 17ada02 | 2014-11-07 22:12:23 +0000 | [diff] [blame] | 115 | "-channel mask set the image channel mask", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 116 | "-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", |
cristy | e4cbe74 | 2010-02-18 22:19:38 +0000 | [diff] [blame] | 125 | "-thumbnail geometry create a thumbnail of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 126 | "-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", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 136 | "-colormap type Shared or Private", |
| 137 | "-colorspace type alternate image colorspace", |
| 138 | "-decipher filename convert cipher pixels to plain pixels", |
| 139 | "-define format:option", |
| 140 | " define one or more image format options", |
| 141 | "-delay value display the next image after pausing", |
| 142 | "-density geometry horizontal and vertical density of the image", |
| 143 | "-depth value image depth", |
| 144 | "-display server display image to this X server", |
| 145 | "-dispose method layer disposal method", |
| 146 | "-dither method apply error diffusion to image", |
| 147 | "-filter type use this filter when resizing an image", |
| 148 | "-format \"string\" output formatted image characteristics", |
| 149 | "-gamma value level of gamma correction", |
| 150 | "-geometry geometry preferred size and location of the Image window", |
| 151 | "-gravity type horizontal and vertical backdrop placement", |
| 152 | "-identify identify the format and characteristics of the image", |
| 153 | "-immutable displayed image cannot be modified", |
| 154 | "-interlace type type of image interlacing scheme", |
| 155 | "-interpolate method pixel color interpolation method", |
| 156 | "-limit type value pixel cache resource limit", |
| 157 | "-loop iterations loop images then exit", |
cristy | e9252c2 | 2013-07-30 15:43:21 +0000 | [diff] [blame] | 158 | "-matte store matte channel if the image has one", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 159 | "-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", |
cristy | e9252c2 | 2013-07-30 15:43:21 +0000 | [diff] [blame] | 170 | "-scenes range image scene range", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 171 | "-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", |
cristy | e9252c2 | 2013-07-30 15:43:21 +0000 | [diff] [blame] | 174 | "-support factor resize support: > 1.0 is blurry, < 1.0 is sharp", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 175 | "-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 | |
cristy | 4f7a613 | 2012-12-23 00:35:19 +0000 | [diff] [blame] | 192 | ListMagickVersion(stdout); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 193 | (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( |
anthony | e5b3965 | 2012-04-21 05:37:29 +0000 | [diff] [blame] | 215 | "\nBy default, the image format of 'file' is determined by its magic\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 216 | (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 | |
| 229 | WandExport 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(); \ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 243 | for (i=0; i < (ssize_t) argc; i++) \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 244 | argv[i]=DestroyString(argv[i]); \ |
| 245 | argv=(char **) RelinquishMagickMemory(argv); \ |
| 246 | } |
| 247 | #define ThrowAnimateException(asperity,tag,option) \ |
| 248 | { \ |
cristy | efe601c | 2013-01-05 17:51:12 +0000 | [diff] [blame] | 249 | (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 250 | option); \ |
| 251 | DestroyAnimate(); \ |
| 252 | return(MagickFalse); \ |
| 253 | } |
| 254 | #define ThrowAnimateInvalidArgumentException(option,argument) \ |
| 255 | { \ |
| 256 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ |
anthony | e5b3965 | 2012-04-21 05:37:29 +0000 | [diff] [blame] | 257 | "InvalidArgument","'%s': %s",option,argument); \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 258 | 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 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 278 | MagickBooleanType |
| 279 | fire, |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 280 | pend, |
| 281 | respect_parenthesis; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 282 | |
| 283 | MagickStatusType |
| 284 | status; |
| 285 | |
| 286 | QuantizeInfo |
| 287 | *quantize_info; |
| 288 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 289 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 290 | i; |
| 291 | |
cristy | 5ed838e | 2010-05-31 00:05:35 +0000 | [diff] [blame] | 292 | ssize_t |
| 293 | j, |
| 294 | k; |
| 295 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 296 | 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 | { |
cristy | 4f7a613 | 2012-12-23 00:35:19 +0000 | [diff] [blame] | 316 | ListMagickVersion(stdout); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 317 | 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; |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 328 | respect_parenthesis=MagickFalse; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 329 | 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); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 341 | for (i=1; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 342 | { |
| 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++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 353 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 354 | 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) |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 380 | ParseCommandOption(MagickInterlaceOptions,MagickFalse,resource_value); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 381 | resource_value=XGetResourceInstance(resource_database,GetClientName(), |
| 382 | "verbose","False"); |
anthony | 2e4501b | 2012-03-30 04:41:54 +0000 | [diff] [blame] | 383 | image_info->verbose=IsStringTrue(resource_value); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 384 | resource_value=XGetResourceInstance(resource_database,GetClientName(), |
| 385 | "dither","True"); |
cristy | cbda611 | 2012-05-27 20:57:16 +0000 | [diff] [blame] | 386 | quantize_info->dither_method=IsStringTrue(resource_value) != MagickFalse ? |
| 387 | RiemersmaDitherMethod : NoDitherMethod; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 388 | /* |
| 389 | Parse command line. |
| 390 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 391 | for (i=1; i <= (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 392 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 393 | if (i < (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 394 | 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 |
cristy | b3ed35e | 2014-06-17 22:48:41 +0000 | [diff] [blame] | 402 | option="-"; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 403 | 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 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 420 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 421 | { |
| 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; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 433 | if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 434 | { |
| 435 | option=argv[++i]; |
| 436 | filename=option; |
| 437 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 438 | if (image_info->ping != MagickFalse) |
cristy | 1b58f25 | 2012-03-01 01:41:41 +0000 | [diff] [blame] | 439 | images=PingImages(image_info,filename,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 440 | else |
cristy | 1b58f25 | 2012-03-01 01:41:41 +0000 | [diff] [blame] | 441 | images=ReadImages(image_info,filename,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 442 | 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 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 456 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 457 | type; |
| 458 | |
| 459 | if (*option == '+') |
| 460 | break; |
| 461 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 462 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 463 | ThrowAnimateException(OptionError,"MissingArgument",option); |
cristy | 288a353 | 2012-08-28 00:19:44 +0000 | [diff] [blame] | 464 | type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 465 | if (type < 0) |
cristy | b15b06c | 2012-08-28 11:36:48 +0000 | [diff] [blame] | 466 | ThrowAnimateException(OptionError,"UnrecognizedAlphaChannelOption", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 467 | argv[i]); |
| 468 | break; |
| 469 | } |
| 470 | if (LocaleCompare("authenticate",option+1) == 0) |
| 471 | { |
| 472 | if (*option == '+') |
| 473 | break; |
| 474 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 475 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 476 | 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++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 493 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 494 | 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++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 503 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 504 | 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++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 514 | if ((i == (ssize_t) argc) || (IsGeometry(argv[i]) == MagickFalse)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 515 | ThrowAnimateException(OptionError,"MissingArgument",option); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 516 | resource_info.border_width=(unsigned int) |
| 517 | StringToUnsignedLong(argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 518 | 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++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 529 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 530 | 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 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 537 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 538 | channel; |
| 539 | |
| 540 | if (*option == '+') |
| 541 | break; |
| 542 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 543 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 544 | 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) |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 560 | ThrowAnimateException(ImageError,"UnableToCloneImage",option); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 561 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 562 | if (*option == '+') |
| 563 | clone_images=CloneImages(clone_images,"-1",exception); |
| 564 | else |
| 565 | { |
| 566 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 567 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 568 | 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++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 586 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 587 | 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++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 604 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 605 | ThrowAnimateException(OptionError,"MissingArgument",option); |
| 606 | if (IsGeometry(argv[i]) == MagickFalse) |
| 607 | ThrowAnimateInvalidArgumentException(option,argv[i]); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 608 | quantize_info->number_colors=StringToUnsignedLong(argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 609 | break; |
| 610 | } |
| 611 | if (LocaleCompare("colorspace",option+1) == 0) |
| 612 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 613 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 614 | colorspace; |
| 615 | |
| 616 | if (*option == '+') |
| 617 | break; |
| 618 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 619 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 620 | ThrowAnimateException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 621 | colorspace=ParseCommandOption(MagickColorspaceOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 622 | MagickFalse,argv[i]); |
| 623 | if (colorspace < 0) |
| 624 | ThrowAnimateException(OptionError,"UnrecognizedColorspace", |
| 625 | argv[i]); |
| 626 | break; |
| 627 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 628 | if (LocaleCompare("concurrent",option+1) == 0) |
| 629 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 630 | if (LocaleCompare("crop",option+1) == 0) |
| 631 | { |
| 632 | if (*option == '+') |
| 633 | break; |
| 634 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 635 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 636 | 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 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 647 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 648 | event; |
| 649 | |
| 650 | if (*option == '+') |
| 651 | break; |
| 652 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 653 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 654 | ThrowAnimateException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 655 | event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 656 | 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++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 667 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 668 | ThrowAnimateException(OptionError,"MissingArgument",option); |
| 669 | break; |
| 670 | } |
| 671 | if (LocaleCompare("define",option+1) == 0) |
| 672 | { |
| 673 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 674 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 675 | 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++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 693 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 694 | 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++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 704 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 705 | 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++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 715 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 716 | 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++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 726 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 727 | ThrowAnimateException(OptionError,"MissingArgument",option); |
| 728 | break; |
| 729 | } |
| 730 | if (LocaleCompare("dispose",option+1) == 0) |
| 731 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 732 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 733 | dispose; |
| 734 | |
| 735 | if (*option == '+') |
| 736 | break; |
| 737 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 738 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 739 | ThrowAnimateException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 740 | dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 741 | if (dispose < 0) |
| 742 | ThrowAnimateException(OptionError,"UnrecognizedDisposeMethod", |
| 743 | argv[i]); |
| 744 | break; |
| 745 | } |
| 746 | if (LocaleCompare("dither",option+1) == 0) |
| 747 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 748 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 749 | method; |
| 750 | |
cristy | cbda611 | 2012-05-27 20:57:16 +0000 | [diff] [blame] | 751 | quantize_info->dither_method=NoDitherMethod; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 752 | if (*option == '+') |
| 753 | break; |
| 754 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 755 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 756 | ThrowAnimateException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 757 | method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 758 | if (method < 0) |
| 759 | ThrowAnimateException(OptionError,"UnrecognizedDitherMethod", |
| 760 | argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 761 | quantize_info->dither_method=(DitherMethod) method; |
| 762 | break; |
| 763 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 764 | if (LocaleCompare("duration",option+1) == 0) |
| 765 | { |
| 766 | if (*option == '+') |
| 767 | break; |
| 768 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 769 | if (i == (ssize_t) argc) |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 770 | ThrowAnimateException(OptionError,"MissingArgument",option); |
| 771 | if (IsGeometry(argv[i]) == MagickFalse) |
| 772 | ThrowAnimateInvalidArgumentException(option,argv[i]); |
| 773 | break; |
| 774 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 775 | ThrowAnimateException(OptionError,"UnrecognizedOption",option); |
| 776 | } |
| 777 | case 'e': |
| 778 | { |
| 779 | if (LocaleCompare("extract",option+1) == 0) |
| 780 | { |
| 781 | if (*option == '+') |
| 782 | break; |
| 783 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 784 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 785 | 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 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 796 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 797 | filter; |
| 798 | |
| 799 | if (*option == '+') |
| 800 | break; |
| 801 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 802 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 803 | ThrowAnimateException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 804 | filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 805 | 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++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 817 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 818 | 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++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 828 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 829 | 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++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 838 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 839 | 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++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 849 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 850 | 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++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 861 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 862 | 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 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 870 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 871 | gravity; |
| 872 | |
| 873 | if (*option == '+') |
| 874 | break; |
| 875 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 876 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 877 | ThrowAnimateException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 878 | gravity=ParseCommandOption(MagickGravityOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 879 | 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++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 902 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 903 | 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 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 923 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 924 | interlace; |
| 925 | |
| 926 | if (*option == '+') |
| 927 | break; |
| 928 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 929 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 930 | ThrowAnimateException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 931 | interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 932 | argv[i]); |
| 933 | if (interlace < 0) |
| 934 | ThrowAnimateException(OptionError,"UnrecognizedInterlaceType", |
| 935 | argv[i]); |
| 936 | break; |
| 937 | } |
| 938 | if (LocaleCompare("interpolate",option+1) == 0) |
| 939 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 940 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 941 | interpolate; |
| 942 | |
| 943 | if (*option == '+') |
| 944 | break; |
| 945 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 946 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 947 | ThrowAnimateException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 948 | interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 949 | 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++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 964 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 965 | 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 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 976 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 977 | resource; |
| 978 | |
| 979 | if (*option == '+') |
| 980 | break; |
| 981 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 982 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 983 | ThrowAnimateException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 984 | resource=ParseCommandOption(MagickResourceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 985 | argv[i]); |
| 986 | if (resource < 0) |
| 987 | ThrowAnimateException(OptionError,"UnrecognizedResourceType", |
| 988 | argv[i]); |
| 989 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 990 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 991 | ThrowAnimateException(OptionError,"MissingArgument",option); |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 992 | value=StringToDouble(argv[i],&p); |
cristy | da16f16 | 2011-02-19 23:52:17 +0000 | [diff] [blame] | 993 | (void) value; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 994 | 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 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1000 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1001 | list; |
| 1002 | |
| 1003 | if (*option == '+') |
| 1004 | break; |
| 1005 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1006 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1007 | ThrowAnimateException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1008 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1009 | if (list < 0) |
| 1010 | ThrowAnimateException(OptionError,"UnrecognizedListType",argv[i]); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 1011 | status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1012 | argv+j,exception); |
| 1013 | DestroyAnimate(); |
cristy | 32ce239 | 2014-09-24 19:08:53 +0000 | [diff] [blame] | 1014 | return(status == 0 ? MagickTrue : MagickFalse); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1015 | } |
| 1016 | if (LocaleCompare("log",option+1) == 0) |
| 1017 | { |
| 1018 | if (*option == '+') |
| 1019 | break; |
| 1020 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1021 | if ((i == (ssize_t) argc) || |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1022 | (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++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 1031 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1032 | 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++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1048 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1049 | 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++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1060 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1061 | 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++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1085 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1086 | 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++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1102 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1103 | ThrowAnimateException(OptionError,"MissingArgument",option); |
| 1104 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1105 | ThrowAnimateInvalidArgumentException(option,argv[i]); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 1106 | resource_info.pause=(unsigned int) StringToUnsignedLong(argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1107 | break; |
| 1108 | } |
| 1109 | if (LocaleCompare("page",option+1) == 0) |
| 1110 | { |
| 1111 | if (*option == '+') |
| 1112 | break; |
| 1113 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1114 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1115 | ThrowAnimateException(OptionError,"MissingArgument",option); |
| 1116 | break; |
| 1117 | } |
| 1118 | if (LocaleCompare("profile",option+1) == 0) |
| 1119 | { |
| 1120 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1121 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1122 | 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 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1131 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1132 | colorspace; |
| 1133 | |
| 1134 | if (*option == '+') |
| 1135 | break; |
| 1136 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 1137 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1138 | ThrowAnimateException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1139 | colorspace=ParseCommandOption(MagickColorspaceOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1140 | 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++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1157 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1158 | 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++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1169 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1170 | 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++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 1180 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1181 | 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++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1191 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1192 | 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++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1205 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1206 | 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++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1220 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1221 | 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++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 1231 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1232 | 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++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1242 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1243 | 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++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1251 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1252 | ThrowAnimateException(OptionError,"MissingArgument",option); |
| 1253 | if (*option == '+') |
| 1254 | break; |
| 1255 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1256 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1257 | 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++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1271 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1272 | 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++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1294 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1295 | 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++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1305 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1306 | 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++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1317 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1318 | 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++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 1327 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1328 | 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++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1337 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1338 | ThrowAnimateException(OptionError,"MissingArgument",option); |
| 1339 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1340 | ThrowAnimateInvalidArgumentException(option,argv[i]); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 1341 | quantize_info->tree_depth=StringToUnsignedLong(argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1342 | 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 | { |
cristy | 4f7a613 | 2012-12-23 00:35:19 +0000 | [diff] [blame] | 1355 | ListMagickVersion(stdout); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1356 | break; |
| 1357 | } |
| 1358 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 1359 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1360 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1361 | method; |
| 1362 | |
| 1363 | if (*option == '+') |
| 1364 | break; |
| 1365 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1366 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1367 | ThrowAnimateException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1368 | method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1369 | 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++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1381 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1382 | 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++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1396 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1397 | 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 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1408 | fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) & |
| 1409 | FireOptionFlag) == 0 ? MagickFalse : MagickTrue; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1410 | if (fire != MagickFalse) |
| 1411 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 1412 | } |
cristy | 259a33e | 2009-11-06 15:22:25 +0000 | [diff] [blame] | 1413 | i--; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1414 | 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); |
cristy | 94f2007 | 2009-09-12 02:12:36 +0000 | [diff] [blame] | 1419 | if (image == (Image *) NULL) |
| 1420 | ThrowAnimateException(OptionError,"MissingAnImageFilename",argv[argc-1]) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1421 | if (resource_info.window_id != (char *) NULL) |
| 1422 | { |
cristy | 051718b | 2011-08-28 22:49:25 +0000 | [diff] [blame] | 1423 | XAnimateBackgroundImage(display,&resource_info,image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1424 | status&=MagickTrue; |
| 1425 | } |
| 1426 | else |
| 1427 | { |
| 1428 | Image |
| 1429 | *animate_image; |
| 1430 | |
| 1431 | /* |
| 1432 | Animate image to X server. |
| 1433 | */ |
cristy | 051718b | 2011-08-28 22:49:25 +0000 | [diff] [blame] | 1434 | animate_image=XAnimateImages(display,&resource_info,argv,argc,image, |
| 1435 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1436 | while (animate_image != (Image *) NULL) |
| 1437 | { |
| 1438 | image=animate_image; |
cristy | 051718b | 2011-08-28 22:49:25 +0000 | [diff] [blame] | 1439 | animate_image=XAnimateImages(display,&resource_info,argv,argc,image, |
| 1440 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1441 | 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, |
anthony | e5b3965 | 2012-04-21 05:37:29 +0000 | [diff] [blame] | 1451 | "DelegateLibrarySupportNotBuiltIn","'%s' (X11)",image_info->filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1452 | return(AnimateUsage()); |
| 1453 | #endif |
| 1454 | } |