PageRenderTime 52ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/scripts/ImageMagick-6.6.2-6/wand/identify.c

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