| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | |
|---|
| 35 | |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | |
|---|
| 44 | |
|---|
| 45 | #include "wand/studio.h" |
|---|
| 46 | #include "wand/MagickWand.h" |
|---|
| 47 | #include "wand/mogrify-private.h" |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 50 | |
|---|
| 51 | |
|---|
| 52 | |
|---|
| 53 | |
|---|
| 54 | |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | |
|---|
| 58 | |
|---|
| 59 | |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 63 | |
|---|
| 64 | |
|---|
| 65 | |
|---|
| 66 | |
|---|
| 67 | |
|---|
| 68 | |
|---|
| 69 | |
|---|
| 70 | |
|---|
| 71 | |
|---|
| 72 | |
|---|
| 73 | |
|---|
| 74 | |
|---|
| 75 | |
|---|
| 76 | |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | |
|---|
| 80 | |
|---|
| 81 | |
|---|
| 82 | |
|---|
| 83 | |
|---|
| 84 | |
|---|
| 85 | |
|---|
| 86 | |
|---|
| 87 | static void IdentifyUsage(void) |
|---|
| 88 | { |
|---|
| 89 | const char |
|---|
| 90 | **p; |
|---|
| 91 | |
|---|
| 92 | static const char |
|---|
| 93 | *miscellaneous[]= |
|---|
| 94 | { |
|---|
| 95 | "-debug events display copious debugging information", |
|---|
| 96 | "-help print program options", |
|---|
| 97 | "-list type print a list of supported option arguments", |
|---|
| 98 | "-log format format of debugging information", |
|---|
| 99 | "-version print version information", |
|---|
| 100 | (char *) NULL |
|---|
| 101 | }, |
|---|
| 102 | *settings[]= |
|---|
| 103 | { |
|---|
| 104 | "-alpha option activate, deactivate, reset, or set the alpha channel", |
|---|
| 105 | "-antialias remove pixel-aliasing", |
|---|
| 106 | "-authenticate password", |
|---|
| 107 | " decipher image with this password", |
|---|
| 108 | "-channel type apply option to select image channels", |
|---|
| 109 | "-colorspace type alternate image colorspace", |
|---|
| 110 | "-crop geometry cut out a rectangular region of the image", |
|---|
| 111 | "-define format:option", |
|---|
| 112 | " define one or more image format options", |
|---|
| 113 | "-density geometry horizontal and vertical density of the image", |
|---|
| 114 | "-depth value image depth", |
|---|
| 115 | "-extract geometry extract area from image", |
|---|
| 116 | "-format \"string\" output formatted image characteristics", |
|---|
| 117 | "-fuzz distance colors within this distance are considered equal", |
|---|
| 118 | "-gamma value level of gamma correction", |
|---|
| 119 | "-interlace type type of image interlacing scheme", |
|---|
| 120 | "-interpolate method pixel color interpolation method", |
|---|
| 121 | "-limit type value pixel cache resource limit", |
|---|
| 122 | "-monitor monitor progress", |
|---|
| 123 | "-ping efficiently determine image attributes", |
|---|
| 124 | "-quiet suppress all warning messages", |
|---|
| 125 | "-regard-warnings pay attention to warning messages", |
|---|
| 126 | "-respect-parenthesis settings remain in effect until parenthesis boundary", |
|---|
| 127 | "-sampling-factor geometry", |
|---|
| 128 | " horizontal and vertical sampling factor", |
|---|
| 129 | "-seed value seed a new sequence of pseudo-random numbers", |
|---|
| 130 | "-set attribute value set an image attribute", |
|---|
| 131 | "-size geometry width and height of image", |
|---|
| 132 | "-strip strip image of all profiles and comments", |
|---|
| 133 | "-units type the units of image resolution", |
|---|
| 134 | "-verbose print detailed information about the image", |
|---|
| 135 | "-virtual-pixel method", |
|---|
| 136 | " virtual pixel access method", |
|---|
| 137 | (char *) NULL |
|---|
| 138 | }; |
|---|
| 139 | |
|---|
| 140 | (void) printf("Version: %s\n",GetMagickVersion((unsigned long *) NULL)); |
|---|
| 141 | (void) printf("Copyright: %s\n\n",GetMagickCopyright()); |
|---|
| 142 | (void) printf("Usage: %s [options ...] file [ [options ...] " |
|---|
| 143 | "file ... ]\n",GetClientName()); |
|---|
| 144 | (void) printf("\nImage Settings:\n"); |
|---|
| 145 | for (p=settings; *p != (char *) NULL; p++) |
|---|
| 146 | (void) printf(" %s\n",*p); |
|---|
| 147 | (void) printf("\nMiscellaneous Options:\n"); |
|---|
| 148 | for (p=miscellaneous; *p != (char *) NULL; p++) |
|---|
| 149 | (void) printf(" %s\n",*p); |
|---|
| 150 | (void) printf( |
|---|
| 151 | "\nBy default, the image format of `file' is determined by its magic\n"); |
|---|
| 152 | (void) printf( |
|---|
| 153 | "number. To specify a particular image format, precede the filename\n"); |
|---|
| 154 | (void) printf( |
|---|
| 155 | "with an image format name and a colon (i.e. ps:image) or specify the\n"); |
|---|
| 156 | (void) printf( |
|---|
| 157 | "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n"); |
|---|
| 158 | (void) printf("'-' for standard input or output.\n"); |
|---|
| 159 | exit(0); |
|---|
| 160 | } |
|---|
| 161 | |
|---|
| 162 | WandExport MagickBooleanType IdentifyImageCommand(ImageInfo *image_info, |
|---|
| 163 | int argc,char **argv,char **metadata,ExceptionInfo *exception) |
|---|
| 164 | { |
|---|
| 165 | #define DestroyIdentify() \ |
|---|
| 166 | { \ |
|---|
| 167 | DestroyImageStack(); \ |
|---|
| 168 | for (i=0; i < (long) argc; i++) \ |
|---|
| 169 | argv[i]=DestroyString(argv[i]); \ |
|---|
| 170 | argv=(char **) RelinquishMagickMemory(argv); \ |
|---|
| 171 | } |
|---|
| 172 | #define ThrowIdentifyException(asperity,tag,option) \ |
|---|
| 173 | { \ |
|---|
| 174 | (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ |
|---|
| 175 | option); \ |
|---|
| 176 | DestroyIdentify(); \ |
|---|
| 177 | return(MagickFalse); \ |
|---|
| 178 | } |
|---|
| 179 | #define ThrowIdentifyInvalidArgumentException(option,argument) \ |
|---|
| 180 | { \ |
|---|
| 181 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ |
|---|
| 182 | "InvalidArgument","`%s': %s",argument,option); \ |
|---|
| 183 | DestroyIdentify(); \ |
|---|
| 184 | return(MagickFalse); \ |
|---|
| 185 | } |
|---|
| 186 | |
|---|
| 187 | const char |
|---|
| 188 | *format, |
|---|
| 189 | *option; |
|---|
| 190 | |
|---|
| 191 | Image |
|---|
| 192 | *image; |
|---|
| 193 | |
|---|
| 194 | ImageStack |
|---|
| 195 | image_stack[MaxImageStackDepth+1]; |
|---|
| 196 | |
|---|
| 197 | long |
|---|
| 198 | j, |
|---|
| 199 | k; |
|---|
| 200 | |
|---|
| 201 | MagickBooleanType |
|---|
| 202 | fire, |
|---|
| 203 | pend; |
|---|
| 204 | |
|---|
| 205 | MagickStatusType |
|---|
| 206 | status; |
|---|
| 207 | |
|---|
| 208 | register long |
|---|
| 209 | i; |
|---|
| 210 | |
|---|
| 211 | unsigned long |
|---|
| 212 | count; |
|---|
| 213 | |
|---|
| 214 | |
|---|
| 215 | |
|---|
| 216 | |
|---|
| 217 | assert(image_info != (ImageInfo *) NULL); |
|---|
| 218 | assert(image_info->signature == MagickSignature); |
|---|
| 219 | if (image_info->debug != MagickFalse) |
|---|
| 220 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); |
|---|
| 221 | assert(exception != (ExceptionInfo *) NULL); |
|---|
| 222 | if (argc == 2) |
|---|
| 223 | { |
|---|
| 224 | option=argv[1]; |
|---|
| 225 | if ((LocaleCompare("version",option+1) == 0) || |
|---|
| 226 | (LocaleCompare("-version",option+1) == 0)) |
|---|
| 227 | { |
|---|
| 228 | (void) fprintf(stdout,"Version: %s\n", |
|---|
| 229 | GetMagickVersion((unsigned long *) NULL)); |
|---|
| 230 | (void) fprintf(stdout,"Copyright: %s\n\n",GetMagickCopyright()); |
|---|
| 231 | return(MagickTrue); |
|---|
| 232 | } |
|---|
| 233 | } |
|---|
| 234 | if (argc < 2) |
|---|
| 235 | IdentifyUsage(); |
|---|
| 236 | count=0; |
|---|
| 237 | format=NULL; |
|---|
| 238 | j=1; |
|---|
| 239 | k=0; |
|---|
| 240 | NewImageStack(); |
|---|
| 241 | option=(char *) NULL; |
|---|
| 242 | pend=MagickFalse; |
|---|
| 243 | status=MagickTrue; |
|---|
| 244 | |
|---|
| 245 | |
|---|
| 246 | |
|---|
| 247 | ReadCommandlLine(argc,&argv); |
|---|
| 248 | status=ExpandFilenames(&argc,&argv); |
|---|
| 249 | if (status == MagickFalse) |
|---|
| 250 | ThrowIdentifyException(ResourceLimitError,"MemoryAllocationFailed", |
|---|
| 251 | strerror(errno)); |
|---|
| 252 | for (i=1; i < (long) argc; i++) |
|---|
| 253 | { |
|---|
| 254 | option=argv[i]; |
|---|
| 255 | if (LocaleCompare(option,"(") == 0) |
|---|
| 256 | { |
|---|
| 257 | FireImageStack(MagickFalse,MagickTrue,pend); |
|---|
| 258 | if (k == MaxImageStackDepth) |
|---|
| 259 | ThrowIdentifyException(OptionError,"ParenthesisNestedTooDeeply", |
|---|
| 260 | option); |
|---|
| 261 | PushImageStack(); |
|---|
| 262 | continue; |
|---|
| 263 | } |
|---|
| 264 | if (LocaleCompare(option,")") == 0) |
|---|
| 265 | { |
|---|
| 266 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
|---|
| 267 | if (k == 0) |
|---|
| 268 | ThrowIdentifyException(OptionError,"UnableToParseExpression",option); |
|---|
| 269 | PopImageStack(); |
|---|
| 270 | continue; |
|---|
| 271 | } |
|---|
| 272 | if (IsMagickOption(option) == MagickFalse) |
|---|
| 273 | { |
|---|
| 274 | char |
|---|
| 275 | *filename; |
|---|
| 276 | |
|---|
| 277 | Image |
|---|
| 278 | *images; |
|---|
| 279 | |
|---|
| 280 | ImageInfo |
|---|
| 281 | *identify_info; |
|---|
| 282 | |
|---|
| 283 | |
|---|
| 284 | |
|---|
| 285 | |
|---|
| 286 | FireImageStack(MagickFalse,MagickFalse,pend); |
|---|
| 287 | identify_info=CloneImageInfo(image_info); |
|---|
| 288 | identify_info->verbose=MagickFalse; |
|---|
| 289 | filename=argv[i]; |
|---|
| 290 | if ((LocaleCompare(filename,"--") == 0) && (i < (argc-1))) |
|---|
| 291 | filename=argv[++i]; |
|---|
| 292 | (void) CopyMagickString(identify_info->filename,filename,MaxTextExtent); |
|---|
| 293 | if (identify_info->ping == MagickFalse) |
|---|
| 294 | images=ReadImage(identify_info,exception); |
|---|
| 295 | else |
|---|
| 296 | images=PingImage(identify_info,exception); |
|---|
| 297 | identify_info=DestroyImageInfo(identify_info); |
|---|
| 298 | status&=(images != (Image *) NULL) && |
|---|
| 299 | (exception->severity < ErrorException); |
|---|
| 300 | if (images == (Image *) NULL) |
|---|
| 301 | continue; |
|---|
| 302 | AppendImageStack(images); |
|---|
| 303 | FireImageStack(MagickFalse,MagickFalse,MagickTrue); |
|---|
| 304 | for ( ; image != (Image *) NULL; image=GetNextImageInList(image)) |
|---|
| 305 | { |
|---|
| 306 | if (image->scene == 0) |
|---|
| 307 | image->scene=count++; |
|---|
| 308 | if (format == (char *) NULL) |
|---|
| 309 | { |
|---|
| 310 | (void) IdentifyImage(image,stdout,image_info->verbose); |
|---|
| 311 | continue; |
|---|
| 312 | } |
|---|
| 313 | if (metadata != (char **) NULL) |
|---|
| 314 | { |
|---|
| 315 | char |
|---|
| 316 | *text; |
|---|
| 317 | |
|---|
| 318 | text=InterpretImageProperties(image_info,image,format); |
|---|
| 319 | if (text == (char *) NULL) |
|---|
| 320 | ThrowIdentifyException(ResourceLimitError, |
|---|
| 321 | "MemoryAllocationFailed",strerror(errno)); |
|---|
| 322 | (void) ConcatenateString(&(*metadata),text); |
|---|
| 323 | text=DestroyString(text); |
|---|
| 324 | if (LocaleCompare(format,"%n") == 0) |
|---|
| 325 | break; |
|---|
| 326 | } |
|---|
| 327 | } |
|---|
| 328 | RemoveAllImageStack(); |
|---|
| 329 | continue; |
|---|
| 330 | } |
|---|
| 331 | pend=image != (Image *) NULL ? MagickTrue : MagickFalse; |
|---|
| 332 | switch (*(option+1)) |
|---|
| 333 | { |
|---|
| 334 | case 'a': |
|---|
| 335 | { |
|---|
| 336 | if (LocaleCompare("alpha",option+1) == 0) |
|---|
| 337 | { |
|---|
| 338 | long |
|---|
| 339 | type; |
|---|
| 340 | |
|---|
| 341 | if (*option == '+') |
|---|
| 342 | break; |
|---|
| 343 | i++; |
|---|
| 344 | if (i == (long) argc) |
|---|
| 345 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
|---|
| 346 | type=ParseMagickOption(MagickAlphaOptions,MagickFalse,argv[i]); |
|---|
| 347 | if (type < 0) |
|---|
| 348 | ThrowIdentifyException(OptionError,"UnrecognizedAlphaChannelType", |
|---|
| 349 | argv[i]); |
|---|
| 350 | break; |
|---|
| 351 | } |
|---|
| 352 | if (LocaleCompare("antialias",option+1) == 0) |
|---|
| 353 | break; |
|---|
| 354 | if (LocaleCompare("authenticate",option+1) == 0) |
|---|
| 355 | { |
|---|
| 356 | if (*option == '+') |
|---|
| 357 | break; |
|---|
| 358 | i++; |
|---|
| 359 | if (i == (long) (argc-1)) |
|---|
| 360 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
|---|
| 361 | break; |
|---|
| 362 | } |
|---|
| 363 | ThrowIdentifyException(OptionError,"UnrecognizedOption",option) |
|---|
| 364 | } |
|---|
| 365 | case 'c': |
|---|
| 366 | { |
|---|
| 367 | if (LocaleCompare("cache",option+1) == 0) |
|---|
| 368 | { |
|---|
| 369 | if (*option == '+') |
|---|
| 370 | break; |
|---|
| 371 | i++; |
|---|
| 372 | if (i == (long) argc) |
|---|
| 373 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
|---|
| 374 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 375 | ThrowIdentifyInvalidArgumentException(option,argv[i]); |
|---|
| 376 | break; |
|---|
| 377 | } |
|---|
| 378 | if (LocaleCompare("channel",option+1) == 0) |
|---|
| 379 | { |
|---|
| 380 | long |
|---|
| 381 | channel; |
|---|
| 382 | |
|---|
| 383 | if (*option == '+') |
|---|
| 384 | break; |
|---|
| 385 | i++; |
|---|
| 386 | if (i == (long) (argc-1)) |
|---|
| 387 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
|---|
| 388 | channel=ParseChannelOption(argv[i]); |
|---|
| 389 | if (channel < 0) |
|---|
| 390 | ThrowIdentifyException(OptionError,"UnrecognizedChannelType", |
|---|
| 391 | argv[i]); |
|---|
| 392 | break; |
|---|
| 393 | } |
|---|
| 394 | if (LocaleCompare("colorspace",option+1) == 0) |
|---|
| 395 | { |
|---|
| 396 | long |
|---|
| 397 | colorspace; |
|---|
| 398 | |
|---|
| 399 | if (*option == '+') |
|---|
| 400 | break; |
|---|
| 401 | i++; |
|---|
| 402 | if (i == (long) (argc-1)) |
|---|
| 403 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
|---|
| 404 | colorspace=ParseMagickOption(MagickColorspaceOptions, |
|---|
| 405 | MagickFalse,argv[i]); |
|---|
| 406 | if (colorspace < 0) |
|---|
| 407 | ThrowIdentifyException(OptionError,"UnrecognizedColorspace", |
|---|
| 408 | argv[i]); |
|---|
| 409 | break; |
|---|
| 410 | } |
|---|
| 411 | if (LocaleCompare("crop",option+1) == 0) |
|---|
| 412 | { |
|---|
| 413 | if (*option == '+') |
|---|
| 414 | break; |
|---|
| 415 | i++; |
|---|
| 416 | if (i == (long) (argc-1)) |
|---|
| 417 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
|---|
| 418 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 419 | ThrowIdentifyInvalidArgumentException(option,argv[i]); |
|---|
| 420 | image_info->ping=MagickFalse; |
|---|
| 421 | break; |
|---|
| 422 | } |
|---|
| 423 | ThrowIdentifyException(OptionError,"UnrecognizedOption",option) |
|---|
| 424 | } |
|---|
| 425 | case 'd': |
|---|
| 426 | { |
|---|
| 427 | if (LocaleCompare("debug",option+1) == 0) |
|---|
| 428 | { |
|---|
| 429 | long |
|---|
| 430 | event; |
|---|
| 431 | |
|---|
| 432 | if (*option == '+') |
|---|
| 433 | break; |
|---|
| 434 | i++; |
|---|
| 435 | if (i == (long) argc) |
|---|
| 436 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
|---|
| 437 | event=ParseMagickOption(MagickLogEventOptions,MagickFalse,argv[i]); |
|---|
| 438 | if (event < 0) |
|---|
| 439 | ThrowIdentifyException(OptionError,"UnrecognizedEventType", |
|---|
| 440 | argv[i]); |
|---|
| 441 | (void) SetLogEventMask(argv[i]); |
|---|
| 442 | break; |
|---|
| 443 | } |
|---|
| 444 | if (LocaleCompare("define",option+1) == 0) |
|---|
| 445 | { |
|---|
| 446 | i++; |
|---|
| 447 | if (i == (long) argc) |
|---|
| 448 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
|---|
| 449 | if (*option == '+') |
|---|
| 450 | { |
|---|
| 451 | const char |
|---|
| 452 | *define; |
|---|
| 453 | |
|---|
| 454 | define=GetImageOption(image_info,argv[i]); |
|---|
| 455 | if (define == (const char *) NULL) |
|---|
| 456 | ThrowIdentifyException(OptionError,"NoSuchOption",argv[i]); |
|---|
| 457 | break; |
|---|
| 458 | } |
|---|
| 459 | break; |
|---|
| 460 | } |
|---|
| 461 | if (LocaleCompare("density",option+1) == 0) |
|---|
| 462 | { |
|---|
| 463 | if (*option == '+') |
|---|
| 464 | break; |
|---|
| 465 | i++; |
|---|
| 466 | if (i == (long) argc) |
|---|
| 467 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
|---|
| 468 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 469 | ThrowIdentifyInvalidArgumentException(option,argv[i]); |
|---|
| 470 | break; |
|---|
| 471 | } |
|---|
| 472 | if (LocaleCompare("depth",option+1) == 0) |
|---|
| 473 | { |
|---|
| 474 | if (*option == '+') |
|---|
| 475 | break; |
|---|
| 476 | i++; |
|---|
| 477 | if (i == (long) argc) |
|---|
| 478 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
|---|
| 479 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 480 | ThrowIdentifyInvalidArgumentException(option,argv[i]); |
|---|
| 481 | break; |
|---|
| 482 | } |
|---|
| 483 | ThrowIdentifyException(OptionError,"UnrecognizedOption",option) |
|---|
| 484 | } |
|---|
| 485 | case 'f': |
|---|
| 486 | { |
|---|
| 487 | if (LocaleCompare("format",option+1) == 0) |
|---|
| 488 | { |
|---|
| 489 | format=(char *) NULL; |
|---|
| 490 | if (*option == '+') |
|---|
| 491 | break; |
|---|
| 492 | i++; |
|---|
| 493 | if (i == (long) argc) |
|---|
| 494 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
|---|
| 495 | format=argv[i]; |
|---|
| 496 | break; |
|---|
| 497 | } |
|---|
| 498 | if (LocaleCompare("fuzz",option+1) == 0) |
|---|
| 499 | { |
|---|
| 500 | if (*option == '+') |
|---|
| 501 | break; |
|---|
| 502 | i++; |
|---|
| 503 | if (i == (long) (argc-1)) |
|---|
| 504 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
|---|
| 505 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 506 | ThrowIdentifyInvalidArgumentException(option,argv[i]); |
|---|
| 507 | break; |
|---|
| 508 | } |
|---|
| 509 | ThrowIdentifyException(OptionError,"UnrecognizedOption",option) |
|---|
| 510 | } |
|---|
| 511 | case 'g': |
|---|
| 512 | { |
|---|
| 513 | if (LocaleCompare("gamma",option+1) == 0) |
|---|
| 514 | { |
|---|
| 515 | i++; |
|---|
| 516 | if (i == (long) (argc-1)) |
|---|
| 517 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
|---|
| 518 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 519 | ThrowIdentifyInvalidArgumentException(option,argv[i]); |
|---|
| 520 | break; |
|---|
| 521 | } |
|---|
| 522 | ThrowIdentifyException(OptionError,"UnrecognizedOption",option) |
|---|
| 523 | } |
|---|
| 524 | case 'h': |
|---|
| 525 | { |
|---|
| 526 | if ((LocaleCompare("help",option+1) == 0) || |
|---|
| 527 | (LocaleCompare("-help",option+1) == 0)) |
|---|
| 528 | IdentifyUsage(); |
|---|
| 529 | ThrowIdentifyException(OptionError,"UnrecognizedOption",option) |
|---|
| 530 | } |
|---|
| 531 | case 'i': |
|---|
| 532 | { |
|---|
| 533 | if (LocaleCompare("interlace",option+1) == 0) |
|---|
| 534 | { |
|---|
| 535 | long |
|---|
| 536 | interlace; |
|---|
| 537 | |
|---|
| 538 | if (*option == '+') |
|---|
| 539 | break; |
|---|
| 540 | i++; |
|---|
| 541 | if (i == (long) argc) |
|---|
| 542 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
|---|
| 543 | interlace=ParseMagickOption(MagickInterlaceOptions,MagickFalse, |
|---|
| 544 | argv[i]); |
|---|
| 545 | if (interlace < 0) |
|---|
| 546 | ThrowIdentifyException(OptionError, |
|---|
| 547 | "UnrecognizedInterlaceType",argv[i]); |
|---|
| 548 | break; |
|---|
| 549 | } |
|---|
| 550 | if (LocaleCompare("interpolate",option+1) == 0) |
|---|
| 551 | { |
|---|
| 552 | long |
|---|
| 553 | interpolate; |
|---|
| 554 | |
|---|
| 555 | if (*option == '+') |
|---|
| 556 | break; |
|---|
| 557 | i++; |
|---|
| 558 | if (i == (long) argc) |
|---|
| 559 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
|---|
| 560 | interpolate=ParseMagickOption(MagickInterpolateOptions,MagickFalse, |
|---|
| 561 | argv[i]); |
|---|
| 562 | if (interpolate < 0) |
|---|
| 563 | ThrowIdentifyException(OptionError, |
|---|
| 564 | "UnrecognizedInterpolateMethod",argv[i]); |
|---|
| 565 | break; |
|---|
| 566 | } |
|---|
| 567 | ThrowIdentifyException(OptionError,"UnrecognizedOption",option) |
|---|
| 568 | } |
|---|
| 569 | case 'l': |
|---|
| 570 | { |
|---|
| 571 | if (LocaleCompare("limit",option+1) == 0) |
|---|
| 572 | { |
|---|
| 573 | char |
|---|
| 574 | *p; |
|---|
| 575 | |
|---|
| 576 | long |
|---|
| 577 | resource; |
|---|
| 578 | |
|---|
| 579 | if (*option == '+') |
|---|
| 580 | break; |
|---|
| 581 | i++; |
|---|
| 582 | if (i == (long) argc) |
|---|
| 583 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
|---|
| 584 | resource=ParseMagickOption(MagickResourceOptions,MagickFalse, |
|---|
| 585 | argv[i]); |
|---|
| 586 | if (resource < 0) |
|---|
| 587 | ThrowIdentifyException(OptionError,"UnrecognizedResourceType", |
|---|
| 588 | argv[i]); |
|---|
| 589 | i++; |
|---|
| 590 | if (i == (long) argc) |
|---|
| 591 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
|---|
| 592 | (void) strtod(argv[i],&p); |
|---|
| 593 | if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) |
|---|
| 594 | ThrowIdentifyInvalidArgumentException(option,argv[i]); |
|---|
| 595 | break; |
|---|
| 596 | } |
|---|
| 597 | if (LocaleCompare("list",option+1) == 0) |
|---|
| 598 | { |
|---|
| 599 | long |
|---|
| 600 | list; |
|---|
| 601 | |
|---|
| 602 | if (*option == '+') |
|---|
| 603 | break; |
|---|
| 604 | i++; |
|---|
| 605 | if (i == (long) argc) |
|---|
| 606 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
|---|
| 607 | list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i]); |
|---|
| 608 | if (list < 0) |
|---|
| 609 | ThrowIdentifyException(OptionError,"UnrecognizedListType", |
|---|
| 610 | argv[i]); |
|---|
| 611 | (void) MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) |
|---|
| 612 | argv+j,exception); |
|---|
| 613 | DestroyIdentify(); |
|---|
| 614 | return(MagickTrue); |
|---|
| 615 | } |
|---|
| 616 | if (LocaleCompare("log",option+1) == 0) |
|---|
| 617 | { |
|---|
| 618 | if (*option == '+') |
|---|
| 619 | break; |
|---|
| 620 | i++; |
|---|
| 621 | if ((i == (long) argc) || |
|---|
| 622 | (strchr(argv[i],'%') == (char *) NULL)) |
|---|
| 623 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
|---|
| 624 | break; |
|---|
| 625 | } |
|---|
| 626 | ThrowIdentifyException(OptionError,"UnrecognizedOption",option) |
|---|
| 627 | } |
|---|
| 628 | case 'm': |
|---|
| 629 | { |
|---|
| 630 | if (LocaleCompare("matte",option+1) == 0) |
|---|
| 631 | break; |
|---|
| 632 | if (LocaleCompare("monitor",option+1) == 0) |
|---|
| 633 | break; |
|---|
| 634 | ThrowIdentifyException(OptionError,"UnrecognizedOption",option) |
|---|
| 635 | } |
|---|
| 636 | case 'p': |
|---|
| 637 | { |
|---|
| 638 | if (LocaleCompare("ping",option+1) == 0) |
|---|
| 639 | break; |
|---|
| 640 | ThrowIdentifyException(OptionError,"UnrecognizedOption",option) |
|---|
| 641 | } |
|---|
| 642 | case 'q': |
|---|
| 643 | { |
|---|
| 644 | if (LocaleCompare("quiet",option+1) == 0) |
|---|
| 645 | break; |
|---|
| 646 | ThrowIdentifyException(OptionError,"UnrecognizedOption",option) |
|---|
| 647 | } |
|---|
| 648 | case 'r': |
|---|
| 649 | { |
|---|
| 650 | if (LocaleCompare("regard-warnings",option+1) == 0) |
|---|
| 651 | break; |
|---|
| 652 | if (LocaleCompare("respect-parenthesis",option+1) == 0) |
|---|
| 653 | { |
|---|
| 654 | respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; |
|---|
| 655 | break; |
|---|
| 656 | } |
|---|
| 657 | ThrowIdentifyException(OptionError,"UnrecognizedOption",option) |
|---|
| 658 | } |
|---|
| 659 | case 's': |
|---|
| 660 | { |
|---|
| 661 | if (LocaleCompare("sampling-factor",option+1) == 0) |
|---|
| 662 | { |
|---|
| 663 | if (*option == '+') |
|---|
| 664 | break; |
|---|
| 665 | i++; |
|---|
| 666 | if (i == (long) argc) |
|---|
| 667 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
|---|
| 668 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 669 | ThrowIdentifyInvalidArgumentException(option,argv[i]); |
|---|
| 670 | break; |
|---|
| 671 | } |
|---|
| 672 | if (LocaleCompare("seed",option+1) == 0) |
|---|
| 673 | { |
|---|
| 674 | if (*option == '+') |
|---|
| 675 | break; |
|---|
| 676 | i++; |
|---|
| 677 | if (i == (long) (argc-1)) |
|---|
| 678 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
|---|
| 679 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 680 | ThrowIdentifyInvalidArgumentException(option,argv[i]); |
|---|
| 681 | break; |
|---|
| 682 | } |
|---|
| 683 | if (LocaleCompare("set",option+1) == 0) |
|---|
| 684 | { |
|---|
| 685 | i++; |
|---|
| 686 | if (i == (long) argc) |
|---|
| 687 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
|---|
| 688 | if (*option == '+') |
|---|
| 689 | break; |
|---|
| 690 | i++; |
|---|
| 691 | if (i == (long) argc) |
|---|
| 692 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
|---|
| 693 | break; |
|---|
| 694 | } |
|---|
| 695 | if (LocaleCompare("size",option+1) == 0) |
|---|
| 696 | { |
|---|
| 697 | if (*option == '+') |
|---|
| 698 | break; |
|---|
| 699 | i++; |
|---|
| 700 | if (i == (long) argc) |
|---|
| 701 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
|---|
| 702 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 703 | ThrowIdentifyInvalidArgumentException(option,argv[i]); |
|---|
| 704 | break; |
|---|
| 705 | } |
|---|
| 706 | if (LocaleCompare("strip",option+1) == 0) |
|---|
| 707 | break; |
|---|
| 708 | if (LocaleCompare("support",option+1) == 0) |
|---|
| 709 | { |
|---|
| 710 | if (*option == '+') |
|---|
| 711 | break; |
|---|
| 712 | i++; |
|---|
| 713 | if (i == (long) argc) |
|---|
| 714 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
|---|
| 715 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 716 | ThrowIdentifyInvalidArgumentException(option,argv[i]); |
|---|
| 717 | break; |
|---|
| 718 | } |
|---|
| 719 | ThrowIdentifyException(OptionError,"UnrecognizedOption",option) |
|---|
| 720 | } |
|---|
| 721 | case 'u': |
|---|
| 722 | { |
|---|
| 723 | if (LocaleCompare("units",option+1) == 0) |
|---|
| 724 | { |
|---|
| 725 | long |
|---|
| 726 | units; |
|---|
| 727 | |
|---|
| 728 | if (*option == '+') |
|---|
| 729 | break; |
|---|
| 730 | i++; |
|---|
| 731 | if (i == (long) (argc-1)) |
|---|
| 732 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
|---|
| 733 | units=ParseMagickOption(MagickResolutionOptions,MagickFalse, |
|---|
| 734 | argv[i]); |
|---|
| 735 | if (units < 0) |
|---|
| 736 | ThrowIdentifyException(OptionError,"UnrecognizedUnitsType", |
|---|
| 737 | argv[i]); |
|---|
| 738 | break; |
|---|
| 739 | } |
|---|
| 740 | ThrowIdentifyException(OptionError,"UnrecognizedOption",option) |
|---|
| 741 | } |
|---|
| 742 | case 'v': |
|---|
| 743 | { |
|---|
| 744 | if (LocaleCompare("verbose",option+1) == 0) |
|---|
| 745 | break; |
|---|
| 746 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
|---|
| 747 | { |
|---|
| 748 | long |
|---|
| 749 | method; |
|---|
| 750 | |
|---|
| 751 | if (*option == '+') |
|---|
| 752 | break; |
|---|
| 753 | i++; |
|---|
| 754 | if (i == (long) (argc-1)) |
|---|
| 755 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
|---|
| 756 | method=ParseMagickOption(MagickVirtualPixelOptions,MagickFalse, |
|---|
| 757 | argv[i]); |
|---|
| 758 | if (method < 0) |
|---|
| 759 | ThrowIdentifyException(OptionError, |
|---|
| 760 | "UnrecognizedVirtualPixelMethod",argv[i]); |
|---|
| 761 | break; |
|---|
| 762 | } |
|---|
| 763 | ThrowIdentifyException(OptionError,"UnrecognizedOption",option) |
|---|
| 764 | } |
|---|
| 765 | case '?': |
|---|
| 766 | break; |
|---|
| 767 | default: |
|---|
| 768 | ThrowIdentifyException(OptionError,"UnrecognizedOption",option) |
|---|
| 769 | } |
|---|
| 770 | fire=ParseMagickOption(MagickMogrifyOptions,MagickFalse,option+1) < 0 ? |
|---|
| 771 | MagickFalse : MagickTrue; |
|---|
| 772 | if (fire != MagickFalse) |
|---|
| 773 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
|---|
| 774 | } |
|---|
| 775 | if (k != 0) |
|---|
| 776 | ThrowIdentifyException(OptionError,"UnbalancedParenthesis",argv[i]); |
|---|
| 777 | if (i != argc) |
|---|
| 778 | ThrowIdentifyException(OptionError,"MissingAnImageFilename",argv[i]); |
|---|
| 779 | DestroyIdentify(); |
|---|
| 780 | return(status != 0 ? MagickTrue : MagickFalse); |
|---|
| 781 | } |
|---|