PageRenderTime 47ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/MagickWand/identify.c

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