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