1 /* 2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 3 % % 4 % % 5 % % 6 % IIIII DDDD EEEEE N N TTTTT IIIII FFFFF Y Y % 7 % I D D E NN N T I F Y Y % 8 % I D D EEE N N N T I FFF Y % 9 % I D D E N NN T I F Y % 10 % IIIII DDDD EEEEE N N T IIIII F Y % 11 % % 12 % % 13 % Identify an Image Format and Characteristics. % 14 % % 15 % Software Design % 16 % Cristy % 17 % September 1994 % 18 % % 19 % % 20 % Copyright 1999-2016 ImageMagick Studio LLC, a non-profit organization % 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 % The identify program describes the format and characteristics of one or more 37 % image files. It also reports if an image is incomplete or corrupt. The 38 % information returned includes the image number, the file name, the width and 39 % height of the image, whether the image is colormapped or not, the number of 40 % colors in the image, the number of bytes in the image, the format of the 41 % image (JPEG, PNM, etc.), and finally the number of seconds it took to read 42 % and process the image. Many more attributes are available with the verbose 43 % option. 44 % 45 */ 46 47 /* 49 Include declarations. 50 */ 51 #include "MagickWand/studio.h" 52 #include "MagickWand/MagickWand.h" 53 #include "MagickWand/mogrify-private.h" 54 #include "MagickCore/string-private.h" 55 56 /* 58 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 59 % % 60 % % 61 % % 62 + I d e n t i f y I m a g e C o m m a n d % 63 % % 64 % % 65 % % 66 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 67 % 68 % IdentifyImageCommand() describes the format and characteristics of one or 69 % more image files. It will also report if an image is incomplete or corrupt. 70 % The information displayed includes the scene number, the file name, the 71 % width and height of the image, whether the image is colormapped or not, 72 % the number of colors in the image, the number of bytes in the image, the 73 % format of the image (JPEG, PNM, etc.), and finally the number of seconds 74 % it took to read and process the image. 75 % 76 % The format of the IdentifyImageCommand method is: 77 % 78 % MagickBooleanType IdentifyImageCommand(ImageInfo *image_info,int argc, 79 % char **argv,char **metadata,ExceptionInfo *exception) 80 % 81 % A description of each parameter follows: 82 % 83 % o image_info: the image info. 84 % 85 % o argc: the number of elements in the argument vector. 86 % 87 % o argv: A text array containing the command line arguments. 88 % 89 % o metadata: any metadata is returned here. 90 % 91 % o exception: return any errors or warnings in this structure. 92 % 93 */ 94 95 static MagickBooleanType IdentifyUsage(void) 96 { 97 const char 98 **p; 99 100 static const char 101 *miscellaneous[]= 102 { 103 "-debug events display copious debugging information", 104 "-help print program options", 105 "-list type print a list of supported option arguments", 106 "-log format format of debugging information", 107 "-version print version information", 108 (char *) NULL 109 }, 110 *operators[]= 111 { 112 "-channel mask set the image channel mask", 113 "-grayscale method convert image to grayscale", 114 "-negate replace every pixel with its complementary color ", 115 (char *) NULL 116 }, 117 *settings[]= 118 { 119 "-alpha option on, activate, off, deactivate, set, opaque, copy", 120 " transparent, extract, background, or shape", 121 "-antialias remove pixel-aliasing", 122 "-authenticate password", 123 " decipher image with this password", 124 "-clip clip along the first path from the 8BIM profile", 125 "-clip-mask filename associate a clip mask with the image", 126 "-clip-path id clip along a named path from the 8BIM profile", 127 "-colorspace type alternate image colorspace", 128 "-crop geometry cut out a rectangular region of the image", 129 "-define format:option", 130 " define one or more image format options", 131 "-density geometry horizontal and vertical density of the image", 132 "-depth value image depth", 133 "-endian type endianness (MSB or LSB) of the image", 134 "-extract geometry extract area from image", 135 "-features distance analyze image features (e.g. contrast, correlation)", 136 "-format \"string\" output formatted image characteristics", 137 "-fuzz distance colors within this distance are considered equal", 138 "-gamma value of gamma correction", 139 "-interlace type type of image interlacing scheme", 140 "-interpolate method pixel color interpolation method", 141 "-limit type value pixel cache resource limit", 142 "-matte store matte channel if the image has one", 143 "-moments report image moments", 144 "-monitor monitor progress", 145 "-ping efficiently determine image attributes", 146 "-precision value maximum number of significant digits to print", 147 "-quiet suppress all warning messages", 148 "-read-mask filename associate a read mask with the image", 149 "-regard-warnings pay attention to warning messages", 150 "-respect-parentheses settings remain in effect until parenthesis boundary", 151 "-sampling-factor geometry", 152 " horizontal and vertical sampling factor", 153 "-seed value seed a new sequence of pseudo-random numbers", 154 "-set attribute value set an image attribute", 155 "-size geometry width and height of image", 156 "-strip strip image of all profiles and comments", 157 "-unique display the number of unique colors in the image", 158 "-units type the units of image resolution", 159 "-verbose print detailed information about the image", 160 "-virtual-pixel method", 161 " virtual pixel access method", 162 (char *) NULL 163 }; 164 165 ListMagickVersion(stdout); 166 (void) printf("Usage: %s [options ...] file [ [options ...] " 167 "file ... ]\n",GetClientName()); 168 (void) printf("\nImage Settings:\n"); 169 for (p=settings; *p != (char *) NULL; p++) 170 (void) printf(" %s\n",*p); 171 (void) printf("\nImage Operators:\n"); 172 for (p=operators; *p != (char *) NULL; p++) 173 (void) printf(" %s\n",*p); 174 (void) printf("\nMiscellaneous Options:\n"); 175 for (p=miscellaneous; *p != (char *) NULL; p++) 176 (void) printf(" %s\n",*p); 177 (void) printf( 178 "\nBy default, the image format of 'file' is determined by its magic\n"); 179 (void) printf( 180 "number. To specify a particular image format, precede the filename\n"); 181 (void) printf( 182 "with an image format name and a colon (i.e. ps:image) or specify the\n"); 183 (void) printf( 184 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n"); 185 (void) printf("'-' for standard input or output.\n"); 186 return(MagickFalse); 187 } 188 189 WandExport MagickBooleanType IdentifyImageCommand(ImageInfo *image_info, 190 int argc,char **argv,char **metadata,ExceptionInfo *exception) 191 { 192 #define DestroyIdentify() \ 193 { \ 194 DestroyImageStack(); \ 195 for (i=0; i < (ssize_t) argc; i++) \ 196 argv[i]=DestroyString(argv[i]); \ 197 argv=(char **) RelinquishMagickMemory(argv); \ 198 } 199 #define ThrowIdentifyException(asperity,tag,option) \ 200 { \ 201 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ 202 option); \ 203 DestroyIdentify(); \ 204 return(MagickFalse); \ 205 } 206 #define ThrowIdentifyInvalidArgumentException(option,argument) \ 207 { \ 208 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ 209 "InvalidArgument","'%s': %s",option,argument); \ 210 DestroyIdentify(); \ 211 return(MagickFalse); \ 212 } 213 214 const char 215 *format, 216 *option; 217 218 Image 219 *image; 220 221 ImageStack 222 image_stack[MaxImageStackDepth+1]; 223 224 MagickBooleanType 225 fire, 226 pend, 227 respect_parenthesis; 228 229 MagickStatusType 230 status; 231 232 register ssize_t 233 i; 234 235 size_t 236 count; 237 238 ssize_t 239 j, 240 k; 241 242 /* 243 Set defaults. 244 */ 245 assert(image_info != (ImageInfo *) NULL); 246 assert(image_info->signature == MagickCoreSignature); 247 if (image_info->debug != MagickFalse) 248 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 249 assert(exception != (ExceptionInfo *) NULL); 250 if (argc == 2) 251 { 252 option=argv[1]; 253 if ((LocaleCompare("version",option+1) == 0) || 254 (LocaleCompare("-version",option+1) == 0)) 255 { 256 ListMagickVersion(stdout); 257 return(MagickTrue); 258 } 259 } 260 if (argc < 2) 261 return(IdentifyUsage()); 262 count=0; 263 format=NULL; 264 j=1; 265 k=0; 266 NewImageStack(); 267 option=(char *) NULL; 268 pend=MagickFalse; 269 respect_parenthesis=MagickFalse; 270 status=MagickTrue; 271 /* 272 Identify an image. 273 */ 274 ReadCommandlLine(argc,&argv); 275 status=ExpandFilenames(&argc,&argv); 276 if (status == MagickFalse) 277 ThrowIdentifyException(ResourceLimitError,"MemoryAllocationFailed", 278 GetExceptionMessage(errno)); 279 image_info->ping=MagickTrue; 280 for (i=1; i < (ssize_t) argc; i++) 281 { 282 option=argv[i]; 283 if (LocaleCompare(option,"(") == 0) 284 { 285 FireImageStack(MagickFalse,MagickTrue,pend); 286 if (k == MaxImageStackDepth) 287 ThrowIdentifyException(OptionError,"ParenthesisNestedTooDeeply", 288 option); 289 PushImageStack(); 290 continue; 291 } 292 if (LocaleCompare(option,")") == 0) 293 { 294 FireImageStack(MagickFalse,MagickTrue,MagickTrue); 295 if (k == 0) 296 ThrowIdentifyException(OptionError,"UnableToParseExpression",option); 297 PopImageStack(); 298 continue; 299 } 300 if (IsCommandOption(option) == MagickFalse) 301 { 302 char 303 *filename; 304 305 Image 306 *images; 307 308 ImageInfo 309 *identify_info; 310 311 /* 312 Read input image. 313 */ 314 FireImageStack(MagickFalse,MagickFalse,pend); 315 identify_info=CloneImageInfo(image_info); 316 identify_info->verbose=MagickFalse; 317 filename=argv[i]; 318 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) 319 filename=argv[++i]; 320 if (identify_info->ping != MagickFalse) 321 images=PingImages(identify_info,filename,exception); 322 else 323 images=ReadImages(identify_info,filename,exception); 324 identify_info=DestroyImageInfo(identify_info); 325 status&=(images != (Image *) NULL) && 326 (exception->severity < ErrorException); 327 if (images == (Image *) NULL) 328 continue; 329 AppendImageStack(images); 330 FinalizeImageSettings(image_info,image,MagickFalse); 331 count=0; 332 for ( ; image != (Image *) NULL; image=GetNextImageInList(image)) 333 { 334 if (image->scene == 0) 335 image->scene=count++; 336 if (format == (char *) NULL) 337 { 338 (void) IdentifyImage(image,stdout,image_info->verbose,exception); 339 continue; 340 } 341 if (metadata != (char **) NULL) 342 { 343 char 344 *text; 345 346 text=InterpretImageProperties(image_info,image,format,exception); 347 if (text == (char *) NULL) 348 ThrowIdentifyException(ResourceLimitError, 349 "MemoryAllocationFailed",GetExceptionMessage(errno)); 350 (void) ConcatenateString(&(*metadata),text); 351 text=DestroyString(text); 352 } 353 } 354 RemoveAllImageStack(); 355 continue; 356 } 357 pend=image != (Image *) NULL ? MagickTrue : MagickFalse; 358 switch (*(option+1)) 359 { 360 case 'a': 361 { 362 if (LocaleCompare("alpha",option+1) == 0) 363 { 364 ssize_t 365 type; 366 367 if (*option == '+') 368 break; 369 i++; 370 if (i == (ssize_t) argc) 371 ThrowIdentifyException(OptionError,"MissingArgument",option); 372 type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse, 373 argv[i]); 374 if (type < 0) 375 ThrowIdentifyException(OptionError, 376 "UnrecognizedAlphaChannelOption",argv[i]); 377 break; 378 } 379 if (LocaleCompare("antialias",option+1) == 0) 380 break; 381 if (LocaleCompare("authenticate",option+1) == 0) 382 { 383 if (*option == '+') 384 break; 385 i++; 386 if (i == (ssize_t) argc) 387 ThrowIdentifyException(OptionError,"MissingArgument",option); 388 break; 389 } 390 ThrowIdentifyException(OptionError,"UnrecognizedOption",option) 391 } 392 case 'c': 393 { 394 if (LocaleCompare("cache",option+1) == 0) 395 { 396 if (*option == '+') 397 break; 398 i++; 399 if (i == (ssize_t) argc) 400 ThrowIdentifyException(OptionError,"MissingArgument",option); 401 if (IsGeometry(argv[i]) == MagickFalse) 402 ThrowIdentifyInvalidArgumentException(option,argv[i]); 403 break; 404 } 405 if (LocaleCompare("channel",option+1) == 0) 406 { 407 ssize_t 408 channel; 409 410 if (*option == '+') 411 break; 412 i++; 413 if (i == (ssize_t) argc) 414 ThrowIdentifyException(OptionError,"MissingArgument",option); 415 channel=ParseChannelOption(argv[i]); 416 if (channel < 0) 417 ThrowIdentifyException(OptionError,"UnrecognizedChannelType", 418 argv[i]); 419 break; 420 } 421 if (LocaleCompare("clip",option+1) == 0) 422 break; 423 if (LocaleCompare("clip-mask",option+1) == 0) 424 { 425 if (*option == '+') 426 break; 427 i++; 428 if (i == (ssize_t) argc) 429 ThrowIdentifyException(OptionError,"MissingArgument",option); 430 break; 431 } 432 if (LocaleCompare("clip-path",option+1) == 0) 433 { 434 i++; 435 if (i == (ssize_t) argc) 436 ThrowIdentifyException(OptionError,"MissingArgument",option); 437 break; 438 } 439 if (LocaleCompare("colorspace",option+1) == 0) 440 { 441 ssize_t 442 colorspace; 443 444 if (*option == '+') 445 break; 446 i++; 447 if (i == (ssize_t) argc) 448 ThrowIdentifyException(OptionError,"MissingArgument",option); 449 colorspace=ParseCommandOption(MagickColorspaceOptions, 450 MagickFalse,argv[i]); 451 if (colorspace < 0) 452 ThrowIdentifyException(OptionError,"UnrecognizedColorspace", 453 argv[i]); 454 break; 455 } 456 if (LocaleCompare("crop",option+1) == 0) 457 { 458 if (*option == '+') 459 break; 460 i++; 461 if (i == (ssize_t) argc) 462 ThrowIdentifyException(OptionError,"MissingArgument",option); 463 if (IsGeometry(argv[i]) == MagickFalse) 464 ThrowIdentifyInvalidArgumentException(option,argv[i]); 465 image_info->ping=MagickFalse; 466 break; 467 } 468 if (LocaleCompare("concurrent",option+1) == 0) 469 break; 470 ThrowIdentifyException(OptionError,"UnrecognizedOption",option) 471 } 472 case 'd': 473 { 474 if (LocaleCompare("debug",option+1) == 0) 475 { 476 ssize_t 477 event; 478 479 if (*option == '+') 480 break; 481 i++; 482 if (i == (ssize_t) argc) 483 ThrowIdentifyException(OptionError,"MissingArgument",option); 484 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]); 485 if (event < 0) 486 ThrowIdentifyException(OptionError,"UnrecognizedEventType", 487 argv[i]); 488 (void) SetLogEventMask(argv[i]); 489 break; 490 } 491 if (LocaleCompare("define",option+1) == 0) 492 { 493 i++; 494 if (i == (ssize_t) argc) 495 ThrowIdentifyException(OptionError,"MissingArgument",option); 496 if (*option == '+') 497 { 498 const char 499 *define; 500 501 define=GetImageOption(image_info,argv[i]); 502 if (define == (const char *) NULL) 503 ThrowIdentifyException(OptionError,"NoSuchOption",argv[i]); 504 break; 505 } 506 if (LocaleNCompare("identify:locate",argv[i],15) == 0) 507 image_info->ping=MagickFalse; 508 break; 509 } 510 if (LocaleCompare("density",option+1) == 0) 511 { 512 if (*option == '+') 513 break; 514 i++; 515 if (i == (ssize_t) argc) 516 ThrowIdentifyException(OptionError,"MissingArgument",option); 517 if (IsGeometry(argv[i]) == MagickFalse) 518 ThrowIdentifyInvalidArgumentException(option,argv[i]); 519 break; 520 } 521 if (LocaleCompare("depth",option+1) == 0) 522 { 523 if (*option == '+') 524 break; 525 i++; 526 if (i == (ssize_t) argc) 527 ThrowIdentifyException(OptionError,"MissingArgument",option); 528 if (IsGeometry(argv[i]) == MagickFalse) 529 ThrowIdentifyInvalidArgumentException(option,argv[i]); 530 break; 531 } 532 if (LocaleCompare("duration",option+1) == 0) 533 { 534 if (*option == '+') 535 break; 536 i++; 537 if (i == (ssize_t) argc) 538 ThrowIdentifyException(OptionError,"MissingArgument",option); 539 if (IsGeometry(argv[i]) == MagickFalse) 540 ThrowIdentifyInvalidArgumentException(option,argv[i]); 541 break; 542 } 543 ThrowIdentifyException(OptionError,"UnrecognizedOption",option) 544 } 545 case 'e': 546 { 547 if (LocaleCompare("endian",option+1) == 0) 548 { 549 ssize_t 550 endian; 551 552 if (*option == '+') 553 break; 554 i++; 555 if (i == (ssize_t) argc) 556 ThrowIdentifyException(OptionError,"MissingArgument",option); 557 endian=ParseCommandOption(MagickEndianOptions,MagickFalse, 558 argv[i]); 559 if (endian < 0) 560 ThrowIdentifyException(OptionError,"UnrecognizedEndianType", 561 argv[i]); 562 break; 563 } 564 ThrowIdentifyException(OptionError,"UnrecognizedOption",option) 565 } 566 case 'f': 567 { 568 if (LocaleCompare("features",option+1) == 0) 569 { 570 if (*option == '+') 571 break; 572 i++; 573 if (i == (ssize_t) argc) 574 ThrowIdentifyException(OptionError,"MissingArgument",option); 575 if (IsGeometry(argv[i]) == MagickFalse) 576 ThrowIdentifyInvalidArgumentException(option,argv[i]); 577 break; 578 } 579 if (LocaleCompare("format",option+1) == 0) 580 { 581 format=(char *) NULL; 582 if (*option == '+') 583 break; 584 i++; 585 if (i == (ssize_t) argc) 586 ThrowIdentifyException(OptionError,"MissingArgument",option); 587 format=argv[i]; 588 break; 589 } 590 if (LocaleCompare("fuzz",option+1) == 0) 591 { 592 if (*option == '+') 593 break; 594 i++; 595 if (i == (ssize_t) argc) 596 ThrowIdentifyException(OptionError,"MissingArgument",option); 597 if (IsGeometry(argv[i]) == MagickFalse) 598 ThrowIdentifyInvalidArgumentException(option,argv[i]); 599 break; 600 } 601 ThrowIdentifyException(OptionError,"UnrecognizedOption",option) 602 } 603 case 'g': 604 { 605 if (LocaleCompare("gamma",option+1) == 0) 606 { 607 i++; 608 if (i == (ssize_t) argc) 609 ThrowIdentifyException(OptionError,"MissingArgument",option); 610 if (IsGeometry(argv[i]) == MagickFalse) 611 ThrowIdentifyInvalidArgumentException(option,argv[i]); 612 break; 613 } 614 if (LocaleCompare("grayscale",option+1) == 0) 615 { 616 ssize_t 617 method; 618 619 if (*option == '+') 620 break; 621 i++; 622 if (i == (ssize_t) argc) 623 ThrowIdentifyException(OptionError,"MissingArgument",option); 624 method=ParseCommandOption(MagickPixelIntensityOptions,MagickFalse, 625 argv[i]); 626 if (method < 0) 627 ThrowIdentifyException(OptionError,"UnrecognizedIntensityMethod", 628 argv[i]); 629 break; 630 } 631 if (LocaleCompare("green-primary",option+1) == 0) 632 { 633 if (*option == '+') 634 break; 635 i++; 636 if (i == (ssize_t) argc) 637 ThrowIdentifyException(OptionError,"MissingArgument",option); 638 if (IsGeometry(argv[i]) == MagickFalse) 639 ThrowIdentifyInvalidArgumentException(option,argv[i]); 640 break; 641 } 642 ThrowIdentifyException(OptionError,"UnrecognizedOption",option) 643 } 644 case 'h': 645 { 646 if ((LocaleCompare("help",option+1) == 0) || 647 (LocaleCompare("-help",option+1) == 0)) 648 return(IdentifyUsage()); 649 ThrowIdentifyException(OptionError,"UnrecognizedOption",option) 650 } 651 case 'i': 652 { 653 if (LocaleCompare("interlace",option+1) == 0) 654 { 655 ssize_t 656 interlace; 657 658 if (*option == '+') 659 break; 660 i++; 661 if (i == (ssize_t) argc) 662 ThrowIdentifyException(OptionError,"MissingArgument",option); 663 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, 664 argv[i]); 665 if (interlace < 0) 666 ThrowIdentifyException(OptionError, 667 "UnrecognizedInterlaceType",argv[i]); 668 break; 669 } 670 if (LocaleCompare("interpolate",option+1) == 0) 671 { 672 ssize_t 673 interpolate; 674 675 if (*option == '+') 676 break; 677 i++; 678 if (i == (ssize_t) argc) 679 ThrowIdentifyException(OptionError,"MissingArgument",option); 680 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse, 681 argv[i]); 682 if (interpolate < 0) 683 ThrowIdentifyException(OptionError, 684 "UnrecognizedInterpolateMethod",argv[i]); 685 break; 686 } 687 ThrowIdentifyException(OptionError,"UnrecognizedOption",option) 688 } 689 case 'l': 690 { 691 if (LocaleCompare("limit",option+1) == 0) 692 { 693 char 694 *p; 695 696 double 697 value; 698 699 ssize_t 700 resource; 701 702 if (*option == '+') 703 break; 704 i++; 705 if (i == (ssize_t) argc) 706 ThrowIdentifyException(OptionError,"MissingArgument",option); 707 resource=ParseCommandOption(MagickResourceOptions,MagickFalse, 708 argv[i]); 709 if (resource < 0) 710 ThrowIdentifyException(OptionError,"UnrecognizedResourceType", 711 argv[i]); 712 i++; 713 if (i == (ssize_t) argc) 714 ThrowIdentifyException(OptionError,"MissingArgument",option); 715 value=StringToDouble(argv[i],&p); 716 (void) value; 717 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) 718 ThrowIdentifyInvalidArgumentException(option,argv[i]); 719 break; 720 } 721 if (LocaleCompare("list",option+1) == 0) 722 { 723 ssize_t 724 list; 725 726 if (*option == '+') 727 break; 728 i++; 729 if (i == (ssize_t) argc) 730 ThrowIdentifyException(OptionError,"MissingArgument",option); 731 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); 732 if (list < 0) 733 ThrowIdentifyException(OptionError,"UnrecognizedListType", 734 argv[i]); 735 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) 736 argv+j,exception); 737 DestroyIdentify(); 738 return(status == 0 ? MagickTrue : MagickFalse); 739 } 740 if (LocaleCompare("log",option+1) == 0) 741 { 742 if (*option == '+') 743 break; 744 i++; 745 if ((i == (ssize_t) argc) || 746 (strchr(argv[i],'%') == (char *) NULL)) 747 ThrowIdentifyException(OptionError,"MissingArgument",option); 748 break; 749 } 750 ThrowIdentifyException(OptionError,"UnrecognizedOption",option) 751 } 752 case 'm': 753 { 754 if (LocaleCompare("mask",option+1) == 0) 755 { 756 if (*option == '+') 757 break; 758 i++; 759 if (i == (ssize_t) argc) 760 ThrowIdentifyException(OptionError,"MissingArgument",option); 761 break; 762 } 763 if (LocaleCompare("matte",option+1) == 0) 764 break; 765 if (LocaleCompare("moments",option+1) == 0) 766 break; 767 if (LocaleCompare("monitor",option+1) == 0) 768 break; 769 ThrowIdentifyException(OptionError,"UnrecognizedOption",option) 770 } 771 case 'n': 772 { 773 if (LocaleCompare("negate",option+1) == 0) 774 break; 775 ThrowIdentifyException(OptionError,"UnrecognizedOption",option) 776 } 777 case 'p': 778 { 779 if (LocaleCompare("ping",option+1) == 0) 780 break; 781 if (LocaleCompare("precision",option+1) == 0) 782 { 783 if (*option == '+') 784 break; 785 i++; 786 if (i == (ssize_t) argc) 787 ThrowIdentifyException(OptionError,"MissingArgument",option); 788 if (IsGeometry(argv[i]) == MagickFalse) 789 ThrowIdentifyInvalidArgumentException(option,argv[i]); 790 break; 791 } 792 ThrowIdentifyException(OptionError,"UnrecognizedOption",option) 793 } 794 case 'q': 795 { 796 if (LocaleCompare("quiet",option+1) == 0) 797 break; 798 ThrowIdentifyException(OptionError,"UnrecognizedOption",option) 799 } 800 case 'r': 801 { 802 if (LocaleCompare("regard-warnings",option+1) == 0) 803 break; 804 if (LocaleNCompare("respect-parentheses",option+1,17) == 0) 805 { 806 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; 807 break; 808 } 809 ThrowIdentifyException(OptionError,"UnrecognizedOption",option) 810 } 811 case 's': 812 { 813 if (LocaleCompare("sampling-factor",option+1) == 0) 814 { 815 if (*option == '+') 816 break; 817 i++; 818 if (i == (ssize_t) argc) 819 ThrowIdentifyException(OptionError,"MissingArgument",option); 820 if (IsGeometry(argv[i]) == MagickFalse) 821 ThrowIdentifyInvalidArgumentException(option,argv[i]); 822 break; 823 } 824 if (LocaleCompare("seed",option+1) == 0) 825 { 826 if (*option == '+') 827 break; 828 i++; 829 if (i == (ssize_t) argc) 830 ThrowIdentifyException(OptionError,"MissingArgument",option); 831 if (IsGeometry(argv[i]) == MagickFalse) 832 ThrowIdentifyInvalidArgumentException(option,argv[i]); 833 break; 834 } 835 if (LocaleCompare("set",option+1) == 0) 836 { 837 i++; 838 if (i == (ssize_t) argc) 839 ThrowIdentifyException(OptionError,"MissingArgument",option); 840 if (*option == '+') 841 break; 842 i++; 843 if (i == (ssize_t) argc) 844 ThrowIdentifyException(OptionError,"MissingArgument",option); 845 break; 846 } 847 if (LocaleCompare("size",option+1) == 0) 848 { 849 if (*option == '+') 850 break; 851 i++; 852 if (i == (ssize_t) argc) 853 ThrowIdentifyException(OptionError,"MissingArgument",option); 854 if (IsGeometry(argv[i]) == MagickFalse) 855 ThrowIdentifyInvalidArgumentException(option,argv[i]); 856 break; 857 } 858 if (LocaleCompare("strip",option+1) == 0) 859 break; 860 if (LocaleCompare("support",option+1) == 0) 861 { 862 if (*option == '+') 863 break; 864 i++; 865 if (i == (ssize_t) argc) 866 ThrowIdentifyException(OptionError,"MissingArgument",option); 867 if (IsGeometry(argv[i]) == MagickFalse) 868 ThrowIdentifyInvalidArgumentException(option,argv[i]); 869 break; 870 } 871 ThrowIdentifyException(OptionError,"UnrecognizedOption",option) 872 } 873 case 'u': 874 { 875 if (LocaleCompare("unique",option+1) == 0) 876 break; 877 if (LocaleCompare("units",option+1) == 0) 878 { 879 ssize_t 880 units; 881 882 if (*option == '+') 883 break; 884 i++; 885 if (i == (ssize_t) argc) 886 ThrowIdentifyException(OptionError,"MissingArgument",option); 887 units=ParseCommandOption(MagickResolutionOptions,MagickFalse, 888 argv[i]); 889 if (units < 0) 890 ThrowIdentifyException(OptionError,"UnrecognizedUnitsType", 891 argv[i]); 892 break; 893 } 894 ThrowIdentifyException(OptionError,"UnrecognizedOption",option) 895 } 896 case 'v': 897 { 898 if (LocaleCompare("verbose",option+1) == 0) 899 break; 900 if (LocaleCompare("virtual-pixel",option+1) == 0) 901 { 902 ssize_t 903 method; 904 905 if (*option == '+') 906 break; 907 i++; 908 if (i == (ssize_t) argc) 909 ThrowIdentifyException(OptionError,"MissingArgument",option); 910 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, 911 argv[i]); 912 if (method < 0) 913 ThrowIdentifyException(OptionError, 914 "UnrecognizedVirtualPixelMethod",argv[i]); 915 break; 916 } 917 ThrowIdentifyException(OptionError,"UnrecognizedOption",option) 918 } 919 case '?': 920 break; 921 default: 922 ThrowIdentifyException(OptionError,"UnrecognizedOption",option) 923 } 924 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) & 925 FireOptionFlag) == 0 ? MagickFalse : MagickTrue; 926 if (fire != MagickFalse) 927 FireImageStack(MagickFalse,MagickTrue,MagickTrue); 928 } 929 if (k != 0) 930 ThrowIdentifyException(OptionError,"UnbalancedParenthesis",argv[i]); 931 if (i != (ssize_t) argc) 932 ThrowIdentifyException(OptionError,"MissingAnImageFilename",argv[i]); 933 DestroyIdentify(); 934 return(status != 0 ? MagickTrue : MagickFalse); 935 } 936