PageRenderTime 41ms CodeModel.GetById 8ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/wand/identify.c

http://github.com/idaunis/binarytiers
C | 838 lines | 714 code | 30 blank | 94 comment | 294 complexity | e4b6bc2571db0e63e4e09fdcc5c39bfb MD5 | raw file
  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-2011 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. respect_parenthesis;
  211. MagickStatusType
  212. status;
  213. register ssize_t
  214. i;
  215. size_t
  216. count;
  217. /*
  218. Set defaults.
  219. */
  220. assert(image_info != (ImageInfo *) NULL);
  221. assert(image_info->signature == MagickSignature);
  222. if (image_info->debug != MagickFalse)
  223. (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
  224. assert(exception != (ExceptionInfo *) NULL);
  225. if (argc == 2)
  226. {
  227. option=argv[1];
  228. if ((LocaleCompare("version",option+1) == 0) ||
  229. (LocaleCompare("-version",option+1) == 0))
  230. {
  231. (void) fprintf(stdout,"Version: %s\n",
  232. GetMagickVersion((size_t *) NULL));
  233. (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
  234. (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
  235. return(MagickFalse);
  236. }
  237. }
  238. if (argc < 2)
  239. return(IdentifyUsage());
  240. count=0;
  241. format=NULL;
  242. j=1;
  243. k=0;
  244. NewImageStack();
  245. option=(char *) NULL;
  246. pend=MagickFalse;
  247. respect_parenthesis=MagickFalse;
  248. status=MagickTrue;
  249. /*
  250. Identify an image.
  251. */
  252. ReadCommandlLine(argc,&argv);
  253. status=ExpandFilenames(&argc,&argv);
  254. if (status == MagickFalse)
  255. ThrowIdentifyException(ResourceLimitError,"MemoryAllocationFailed",
  256. GetExceptionMessage(errno));
  257. image_info->ping=MagickTrue;
  258. for (i=1; i < (ssize_t) argc; i++)
  259. {
  260. option=argv[i];
  261. if (LocaleCompare(option,"(") == 0)
  262. {
  263. FireImageStack(MagickFalse,MagickTrue,pend);
  264. if (k == MaxImageStackDepth)
  265. ThrowIdentifyException(OptionError,"ParenthesisNestedTooDeeply",
  266. option);
  267. PushImageStack();
  268. continue;
  269. }
  270. if (LocaleCompare(option,")") == 0)
  271. {
  272. FireImageStack(MagickFalse,MagickTrue,MagickTrue);
  273. if (k == 0)
  274. ThrowIdentifyException(OptionError,"UnableToParseExpression",option);
  275. PopImageStack();
  276. continue;
  277. }
  278. if (IsMagickOption(option) == MagickFalse)
  279. {
  280. char
  281. *filename;
  282. Image
  283. *images;
  284. ImageInfo
  285. *identify_info;
  286. /*
  287. Read input image.
  288. */
  289. FireImageStack(MagickFalse,MagickFalse,pend);
  290. identify_info=CloneImageInfo(image_info);
  291. identify_info->verbose=MagickFalse;
  292. filename=argv[i];
  293. if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
  294. filename=argv[++i];
  295. (void) CopyMagickString(identify_info->filename,filename,MaxTextExtent);
  296. if (identify_info->ping != MagickFalse)
  297. images=PingImages(identify_info,exception);
  298. else
  299. images=ReadImages(identify_info,exception);
  300. identify_info=DestroyImageInfo(identify_info);
  301. status&=(images != (Image *) NULL) &&
  302. (exception->severity < ErrorException);
  303. if (images == (Image *) NULL)
  304. continue;
  305. AppendImageStack(images);
  306. FinalizeImageSettings(image_info,image,MagickFalse);
  307. for ( ; image != (Image *) NULL; image=GetNextImageInList(image))
  308. {
  309. if (image->scene == 0)
  310. image->scene=count++;
  311. if (format == (char *) NULL)
  312. {
  313. (void) IdentifyImage(image,stdout,image_info->verbose);
  314. continue;
  315. }
  316. if (metadata != (char **) NULL)
  317. {
  318. char
  319. *text;
  320. text=InterpretImageProperties(image_info,image,format);
  321. if (text == (char *) NULL)
  322. ThrowIdentifyException(ResourceLimitError,
  323. "MemoryAllocationFailed",GetExceptionMessage(errno));
  324. (void) ConcatenateString(&(*metadata),text);
  325. text=DestroyString(text);
  326. if (LocaleCompare(format,"%n") == 0)
  327. break;
  328. }
  329. }
  330. RemoveAllImageStack();
  331. continue;
  332. }
  333. pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
  334. switch (*(option+1))
  335. {
  336. case 'a':
  337. {
  338. if (LocaleCompare("alpha",option+1) == 0)
  339. {
  340. ssize_t
  341. type;
  342. if (*option == '+')
  343. break;
  344. i++;
  345. if (i == (ssize_t) argc)
  346. ThrowIdentifyException(OptionError,"MissingArgument",option);
  347. type=ParseMagickOption(MagickAlphaOptions,MagickFalse,argv[i]);
  348. if (type < 0)
  349. ThrowIdentifyException(OptionError,"UnrecognizedAlphaChannelType",
  350. argv[i]);
  351. break;
  352. }
  353. if (LocaleCompare("antialias",option+1) == 0)
  354. break;
  355. if (LocaleCompare("authenticate",option+1) == 0)
  356. {
  357. if (*option == '+')
  358. break;
  359. i++;
  360. if (i == (ssize_t) (argc-1))
  361. ThrowIdentifyException(OptionError,"MissingArgument",option);
  362. break;
  363. }
  364. ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
  365. }
  366. case 'c':
  367. {
  368. if (LocaleCompare("cache",option+1) == 0)
  369. {
  370. if (*option == '+')
  371. break;
  372. i++;
  373. if (i == (ssize_t) argc)
  374. ThrowIdentifyException(OptionError,"MissingArgument",option);
  375. if (IsGeometry(argv[i]) == MagickFalse)
  376. ThrowIdentifyInvalidArgumentException(option,argv[i]);
  377. break;
  378. }
  379. if (LocaleCompare("channel",option+1) == 0)
  380. {
  381. ssize_t
  382. channel;
  383. if (*option == '+')
  384. break;
  385. i++;
  386. if (i == (ssize_t) (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. ssize_t
  397. colorspace;
  398. if (*option == '+')
  399. break;
  400. i++;
  401. if (i == (ssize_t) (argc-1))
  402. ThrowIdentifyException(OptionError,"MissingArgument",option);
  403. colorspace=ParseMagickOption(MagickColorspaceOptions,
  404. MagickFalse,argv[i]);
  405. if (colorspace < 0)
  406. ThrowIdentifyException(OptionError,"UnrecognizedColorspace",
  407. argv[i]);
  408. break;
  409. }
  410. if (LocaleCompare("crop",option+1) == 0)
  411. {
  412. if (*option == '+')
  413. break;
  414. i++;
  415. if (i == (ssize_t) (argc-1))
  416. ThrowIdentifyException(OptionError,"MissingArgument",option);
  417. if (IsGeometry(argv[i]) == MagickFalse)
  418. ThrowIdentifyInvalidArgumentException(option,argv[i]);
  419. image_info->ping=MagickFalse;
  420. break;
  421. }
  422. if (LocaleCompare("concurrent",option+1) == 0)
  423. break;
  424. ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
  425. }
  426. case 'd':
  427. {
  428. if (LocaleCompare("debug",option+1) == 0)
  429. {
  430. ssize_t
  431. event;
  432. if (*option == '+')
  433. break;
  434. i++;
  435. if (i == (ssize_t) 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 == (ssize_t) argc)
  448. ThrowIdentifyException(OptionError,"MissingArgument",option);
  449. if (*option == '+')
  450. {
  451. const char
  452. *define;
  453. define=GetImageOption(image_info,argv[i]);
  454. if (define == (const char *) NULL)
  455. ThrowIdentifyException(OptionError,"NoSuchOption",argv[i]);
  456. break;
  457. }
  458. break;
  459. }
  460. if (LocaleCompare("density",option+1) == 0)
  461. {
  462. if (*option == '+')
  463. break;
  464. i++;
  465. if (i == (ssize_t) argc)
  466. ThrowIdentifyException(OptionError,"MissingArgument",option);
  467. if (IsGeometry(argv[i]) == MagickFalse)
  468. ThrowIdentifyInvalidArgumentException(option,argv[i]);
  469. break;
  470. }
  471. if (LocaleCompare("depth",option+1) == 0)
  472. {
  473. if (*option == '+')
  474. break;
  475. i++;
  476. if (i == (ssize_t) argc)
  477. ThrowIdentifyException(OptionError,"MissingArgument",option);
  478. if (IsGeometry(argv[i]) == MagickFalse)
  479. ThrowIdentifyInvalidArgumentException(option,argv[i]);
  480. break;
  481. }
  482. if (LocaleCompare("duration",option+1) == 0)
  483. {
  484. if (*option == '+')
  485. break;
  486. i++;
  487. if (i == (ssize_t) (argc-1))
  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("features",option+1) == 0)
  498. {
  499. if (*option == '+')
  500. break;
  501. i++;
  502. if (i == (ssize_t) (argc-1))
  503. ThrowIdentifyException(OptionError,"MissingArgument",option);
  504. if (IsGeometry(argv[i]) == MagickFalse)
  505. ThrowIdentifyInvalidArgumentException(option,argv[i]);
  506. break;
  507. }
  508. if (LocaleCompare("format",option+1) == 0)
  509. {
  510. format=(char *) NULL;
  511. if (*option == '+')
  512. break;
  513. i++;
  514. if (i == (ssize_t) argc)
  515. ThrowIdentifyException(OptionError,"MissingArgument",option);
  516. format=argv[i];
  517. break;
  518. }
  519. if (LocaleCompare("fuzz",option+1) == 0)
  520. {
  521. if (*option == '+')
  522. break;
  523. i++;
  524. if (i == (ssize_t) (argc-1))
  525. ThrowIdentifyException(OptionError,"MissingArgument",option);
  526. if (IsGeometry(argv[i]) == MagickFalse)
  527. ThrowIdentifyInvalidArgumentException(option,argv[i]);
  528. break;
  529. }
  530. ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
  531. }
  532. case 'g':
  533. {
  534. if (LocaleCompare("gamma",option+1) == 0)
  535. {
  536. i++;
  537. if (i == (ssize_t) (argc-1))
  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 'h':
  546. {
  547. if ((LocaleCompare("help",option+1) == 0) ||
  548. (LocaleCompare("-help",option+1) == 0))
  549. return(IdentifyUsage());
  550. ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
  551. }
  552. case 'i':
  553. {
  554. if (LocaleCompare("interlace",option+1) == 0)
  555. {
  556. ssize_t
  557. interlace;
  558. if (*option == '+')
  559. break;
  560. i++;
  561. if (i == (ssize_t) argc)
  562. ThrowIdentifyException(OptionError,"MissingArgument",option);
  563. interlace=ParseMagickOption(MagickInterlaceOptions,MagickFalse,
  564. argv[i]);
  565. if (interlace < 0)
  566. ThrowIdentifyException(OptionError,
  567. "UnrecognizedInterlaceType",argv[i]);
  568. break;
  569. }
  570. if (LocaleCompare("interpolate",option+1) == 0)
  571. {
  572. ssize_t
  573. interpolate;
  574. if (*option == '+')
  575. break;
  576. i++;
  577. if (i == (ssize_t) argc)
  578. ThrowIdentifyException(OptionError,"MissingArgument",option);
  579. interpolate=ParseMagickOption(MagickInterpolateOptions,MagickFalse,
  580. argv[i]);
  581. if (interpolate < 0)
  582. ThrowIdentifyException(OptionError,
  583. "UnrecognizedInterpolateMethod",argv[i]);
  584. break;
  585. }
  586. ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
  587. }
  588. case 'l':
  589. {
  590. if (LocaleCompare("limit",option+1) == 0)
  591. {
  592. char
  593. *p;
  594. double
  595. value;
  596. ssize_t
  597. resource;
  598. if (*option == '+')
  599. break;
  600. i++;
  601. if (i == (ssize_t) argc)
  602. ThrowIdentifyException(OptionError,"MissingArgument",option);
  603. resource=ParseMagickOption(MagickResourceOptions,MagickFalse,
  604. argv[i]);
  605. if (resource < 0)
  606. ThrowIdentifyException(OptionError,"UnrecognizedResourceType",
  607. argv[i]);
  608. i++;
  609. if (i == (ssize_t) argc)
  610. ThrowIdentifyException(OptionError,"MissingArgument",option);
  611. value=strtod(argv[i],&p);
  612. (void) value;
  613. if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
  614. ThrowIdentifyInvalidArgumentException(option,argv[i]);
  615. break;
  616. }
  617. if (LocaleCompare("list",option+1) == 0)
  618. {
  619. ssize_t
  620. list;
  621. if (*option == '+')
  622. break;
  623. i++;
  624. if (i == (ssize_t) argc)
  625. ThrowIdentifyException(OptionError,"MissingArgument",option);
  626. list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i]);
  627. if (list < 0)
  628. ThrowIdentifyException(OptionError,"UnrecognizedListType",
  629. argv[i]);
  630. status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
  631. argv+j,exception);
  632. DestroyIdentify();
  633. return(status != 0 ? MagickFalse : MagickTrue);
  634. }
  635. if (LocaleCompare("log",option+1) == 0)
  636. {
  637. if (*option == '+')
  638. break;
  639. i++;
  640. if ((i == (ssize_t) argc) ||
  641. (strchr(argv[i],'%') == (char *) NULL))
  642. ThrowIdentifyException(OptionError,"MissingArgument",option);
  643. break;
  644. }
  645. ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
  646. }
  647. case 'm':
  648. {
  649. if (LocaleCompare("matte",option+1) == 0)
  650. break;
  651. if (LocaleCompare("monitor",option+1) == 0)
  652. break;
  653. ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
  654. }
  655. case 'n':
  656. {
  657. if (LocaleCompare("negate",option+1) == 0)
  658. break;
  659. ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
  660. }
  661. case 'p':
  662. {
  663. if (LocaleCompare("ping",option+1) == 0)
  664. break;
  665. ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
  666. }
  667. case 'q':
  668. {
  669. if (LocaleCompare("quiet",option+1) == 0)
  670. break;
  671. ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
  672. }
  673. case 'r':
  674. {
  675. if (LocaleCompare("regard-warnings",option+1) == 0)
  676. break;
  677. if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
  678. {
  679. respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
  680. break;
  681. }
  682. ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
  683. }
  684. case 's':
  685. {
  686. if (LocaleCompare("sampling-factor",option+1) == 0)
  687. {
  688. if (*option == '+')
  689. break;
  690. i++;
  691. if (i == (ssize_t) argc)
  692. ThrowIdentifyException(OptionError,"MissingArgument",option);
  693. if (IsGeometry(argv[i]) == MagickFalse)
  694. ThrowIdentifyInvalidArgumentException(option,argv[i]);
  695. break;
  696. }
  697. if (LocaleCompare("seed",option+1) == 0)
  698. {
  699. if (*option == '+')
  700. break;
  701. i++;
  702. if (i == (ssize_t) (argc-1))
  703. ThrowIdentifyException(OptionError,"MissingArgument",option);
  704. if (IsGeometry(argv[i]) == MagickFalse)
  705. ThrowIdentifyInvalidArgumentException(option,argv[i]);
  706. break;
  707. }
  708. if (LocaleCompare("set",option+1) == 0)
  709. {
  710. i++;
  711. if (i == (ssize_t) argc)
  712. ThrowIdentifyException(OptionError,"MissingArgument",option);
  713. if (*option == '+')
  714. break;
  715. i++;
  716. if (i == (ssize_t) argc)
  717. ThrowIdentifyException(OptionError,"MissingArgument",option);
  718. break;
  719. }
  720. if (LocaleCompare("size",option+1) == 0)
  721. {
  722. if (*option == '+')
  723. break;
  724. i++;
  725. if (i == (ssize_t) argc)
  726. ThrowIdentifyException(OptionError,"MissingArgument",option);
  727. if (IsGeometry(argv[i]) == MagickFalse)
  728. ThrowIdentifyInvalidArgumentException(option,argv[i]);
  729. break;
  730. }
  731. if (LocaleCompare("strip",option+1) == 0)
  732. break;
  733. if (LocaleCompare("support",option+1) == 0)
  734. {
  735. if (*option == '+')
  736. break;
  737. i++;
  738. if (i == (ssize_t) argc)
  739. ThrowIdentifyException(OptionError,"MissingArgument",option);
  740. if (IsGeometry(argv[i]) == MagickFalse)
  741. ThrowIdentifyInvalidArgumentException(option,argv[i]);
  742. break;
  743. }
  744. ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
  745. }
  746. case 'u':
  747. {
  748. if (LocaleCompare("unique",option+1) == 0)
  749. break;
  750. if (LocaleCompare("units",option+1) == 0)
  751. {
  752. ssize_t
  753. units;
  754. if (*option == '+')
  755. break;
  756. i++;
  757. if (i == (ssize_t) (argc-1))
  758. ThrowIdentifyException(OptionError,"MissingArgument",option);
  759. units=ParseMagickOption(MagickResolutionOptions,MagickFalse,
  760. argv[i]);
  761. if (units < 0)
  762. ThrowIdentifyException(OptionError,"UnrecognizedUnitsType",
  763. argv[i]);
  764. break;
  765. }
  766. ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
  767. }
  768. case 'v':
  769. {
  770. if (LocaleCompare("verbose",option+1) == 0)
  771. break;
  772. if (LocaleCompare("virtual-pixel",option+1) == 0)
  773. {
  774. ssize_t
  775. method;
  776. if (*option == '+')
  777. break;
  778. i++;
  779. if (i == (ssize_t) (argc-1))
  780. ThrowIdentifyException(OptionError,"MissingArgument",option);
  781. method=ParseMagickOption(MagickVirtualPixelOptions,MagickFalse,
  782. argv[i]);
  783. if (method < 0)
  784. ThrowIdentifyException(OptionError,
  785. "UnrecognizedVirtualPixelMethod",argv[i]);
  786. break;
  787. }
  788. ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
  789. }
  790. case '?':
  791. break;
  792. default:
  793. ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
  794. }
  795. fire=ParseMagickOption(MagickImageListOptions,MagickFalse,option+1) < 0 ?
  796. MagickFalse : MagickTrue;
  797. if (fire != MagickFalse)
  798. FireImageStack(MagickFalse,MagickTrue,MagickTrue);
  799. }
  800. if (k != 0)
  801. ThrowIdentifyException(OptionError,"UnbalancedParenthesis",argv[i]);
  802. if (i != (ssize_t) argc)
  803. ThrowIdentifyException(OptionError,"MissingAnImageFilename",argv[i]);
  804. DestroyIdentify();
  805. return(status != 0 ? MagickTrue : MagickFalse);
  806. }