PageRenderTime 45ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/MagickWand/stream.c

https://gitlab.com/ImageMagick/ImageMagick
C | 750 lines | 635 code | 28 blank | 87 comment | 260 complexity | 48b0f1d86ad68789b0b6089974e75013 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception
  1. /*
  2. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  3. % %
  4. % %
  5. % %
  6. % SSSSS TTTTT RRRR EEEEE AAA M M %
  7. % SS T R R E A A MM MM %
  8. % SSS T RRRR EEE AAAAA M M M %
  9. % SS T R R E A A M M %
  10. % SSSSS T R R EEEEE A A M M %
  11. % %
  12. % %
  13. % Stream Image to a Raw Image Format %
  14. % %
  15. % Software Design %
  16. % Cristy %
  17. % July 1992 %
  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. % Stream is a lightweight tool to stream one or more pixel components of the
  37. % image or portion of the image to your choice of storage formats. It writes
  38. % the pixel components as they are read from the input image a row at a time
  39. % making stream desirable when working with large images or when you require
  40. % raw pixel components.
  41. %
  42. */
  43. /*
  44. Include declarations.
  45. */
  46. #include "MagickWand/studio.h"
  47. #include "MagickWand/MagickWand.h"
  48. #include "MagickWand/mogrify-private.h"
  49. #include "MagickCore/stream-private.h"
  50. #include "MagickCore/string-private.h"
  51. /*
  52. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  53. % %
  54. % %
  55. % %
  56. % S t r e a m I m a g e C o m m a n d %
  57. % %
  58. % %
  59. % %
  60. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  61. %
  62. % StreamImageCommand() is a lightweight method designed to extract pixels
  63. % from large image files to a raw format using a minimum of system resources.
  64. % The entire image or any regular portion of the image can be extracted.
  65. %
  66. % The format of the StreamImageCommand method is:
  67. %
  68. % MagickBooleanType StreamImageCommand(ImageInfo *image_info,int argc,
  69. % char **argv,char **metadata,ExceptionInfo *exception)
  70. %
  71. % A description of each parameter follows:
  72. %
  73. % o image_info: the image info.
  74. %
  75. % o argc: the number of elements in the argument vector.
  76. %
  77. % o argv: A text array containing the command line arguments.
  78. %
  79. % o metadata: any metadata is returned here.
  80. %
  81. % o exception: return any errors or warnings in this structure.
  82. %
  83. */
  84. static MagickBooleanType StreamUsage(void)
  85. {
  86. static const char
  87. miscellaneous[] =
  88. " -channel mask set the image channel mask\n"
  89. " -debug events display copious debugging information\n"
  90. " -help print program options\n"
  91. " -list type print a list of supported option arguments\n"
  92. " -log format format of debugging information\n"
  93. " -version print version information",
  94. settings[] =
  95. " -authenticate password\n"
  96. " decipher image with this password\n"
  97. " -colorspace type alternate image colorspace\n"
  98. " -compress type type of pixel compression when writing the image\n"
  99. " -define format:option\n"
  100. " define one or more image format options\n"
  101. " -density geometry horizontal and vertical density of the image\n"
  102. " -depth value image depth\n"
  103. " -extract geometry extract area from image\n"
  104. " -identify identify the format and characteristics of the image\n"
  105. " -interlace type type of image interlacing scheme\n"
  106. " -interpolate method pixel color interpolation method\n"
  107. " -limit type value pixel cache resource limit\n"
  108. " -map components one or more pixel components\n"
  109. " -monitor monitor progress\n"
  110. " -quantize colorspace reduce colors in this colorspace\n"
  111. " -quiet suppress all warning messages\n"
  112. " -regard-warnings pay attention to warning messages\n"
  113. " -respect-parentheses settings remain in effect until parenthesis boundary\n"
  114. " -sampling-factor geometry\n"
  115. " horizontal and vertical sampling factor\n"
  116. " -seed value seed a new sequence of pseudo-random numbers\n"
  117. " -set attribute value set an image attribute\n"
  118. " -size geometry width and height of image\n"
  119. " -storage-type type pixel storage type\n"
  120. " -synchronize synchronize image to storage device\n"
  121. " -taint declare the image as modified\n"
  122. " -transparent-color color\n"
  123. " transparent color\n"
  124. " -verbose print detailed information about the image\n"
  125. " -virtual-pixel method\n"
  126. " virtual pixel access method";
  127. ListMagickVersion(stdout);
  128. (void) printf("Usage: %s [options ...] input-image raw-image\n",
  129. GetClientName());
  130. (void) printf("\nImage Settings:\n");
  131. (void) puts(settings);
  132. (void) printf("\nMiscellaneous Options:\n");
  133. (void) puts(miscellaneous);
  134. (void) printf(
  135. "\nBy default, the image format of 'file' is determined by its magic\n");
  136. (void) printf(
  137. "number. To specify a particular image format, precede the filename\n");
  138. (void) printf(
  139. "with an image format name and a colon (i.e. ps:image) or specify the\n");
  140. (void) printf(
  141. "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
  142. (void) printf("'-' for standard input or output.\n");
  143. return(MagickFalse);
  144. }
  145. WandExport MagickBooleanType StreamImageCommand(ImageInfo *image_info,
  146. int argc,char **argv,char **metadata,ExceptionInfo *exception)
  147. {
  148. #define DestroyStream() \
  149. { \
  150. DestroyImageStack(); \
  151. stream_info=DestroyStreamInfo(stream_info); \
  152. for (i=0; i < (ssize_t) argc; i++) \
  153. argv[i]=DestroyString(argv[i]); \
  154. argv=(char **) RelinquishMagickMemory(argv); \
  155. }
  156. #define ThrowStreamException(asperity,tag,option) \
  157. { \
  158. (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
  159. option); \
  160. DestroyStream(); \
  161. return(MagickFalse); \
  162. }
  163. #define ThrowStreamInvalidArgumentException(option,argument) \
  164. { \
  165. (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
  166. "InvalidArgument","'%s': %s",option,argument); \
  167. DestroyStream(); \
  168. return(MagickFalse); \
  169. }
  170. char
  171. *filename,
  172. *option;
  173. const char
  174. *format;
  175. Image
  176. *image;
  177. ImageStack
  178. image_stack[MaxImageStackDepth+1];
  179. MagickBooleanType
  180. fire,
  181. pend,
  182. respect_parenthesis;
  183. MagickStatusType
  184. status;
  185. register ssize_t
  186. i;
  187. ssize_t
  188. j,
  189. k;
  190. StreamInfo
  191. *stream_info;
  192. /*
  193. Set defaults.
  194. */
  195. assert(image_info != (ImageInfo *) NULL);
  196. assert(image_info->signature == MagickCoreSignature);
  197. if (image_info->debug != MagickFalse)
  198. (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
  199. assert(exception != (ExceptionInfo *) NULL);
  200. (void) metadata;
  201. if (argc == 2)
  202. {
  203. option=argv[1];
  204. if ((LocaleCompare("version",option+1) == 0) ||
  205. (LocaleCompare("-version",option+1) == 0))
  206. {
  207. ListMagickVersion(stdout);
  208. return(MagickFalse);
  209. }
  210. }
  211. if (argc < 3)
  212. return(StreamUsage());
  213. format="%w,%h,%m";
  214. (void) format;
  215. j=1;
  216. k=0;
  217. NewImageStack();
  218. option=(char *) NULL;
  219. pend=MagickFalse;
  220. respect_parenthesis=MagickFalse;
  221. stream_info=AcquireStreamInfo(image_info,exception);
  222. status=MagickTrue;
  223. /*
  224. Stream an image.
  225. */
  226. ReadCommandlLine(argc,&argv);
  227. status=ExpandFilenames(&argc,&argv);
  228. if (status == MagickFalse)
  229. ThrowStreamException(ResourceLimitError,"MemoryAllocationFailed",
  230. GetExceptionMessage(errno));
  231. status=OpenStream(image_info,stream_info,argv[argc-1],exception);
  232. if (status == MagickFalse)
  233. {
  234. DestroyStream();
  235. return(MagickFalse);
  236. }
  237. for (i=1; i < (ssize_t) (argc-1); i++)
  238. {
  239. option=argv[i];
  240. if (LocaleCompare(option,"(") == 0)
  241. {
  242. FireImageStack(MagickFalse,MagickTrue,pend);
  243. if (k == MaxImageStackDepth)
  244. ThrowStreamException(OptionError,"ParenthesisNestedTooDeeply",option);
  245. PushImageStack();
  246. continue;
  247. }
  248. if (LocaleCompare(option,")") == 0)
  249. {
  250. FireImageStack(MagickFalse,MagickTrue,MagickTrue);
  251. if (k == 0)
  252. ThrowStreamException(OptionError,"UnableToParseExpression",option);
  253. PopImageStack();
  254. continue;
  255. }
  256. if (IsCommandOption(option) == MagickFalse)
  257. {
  258. Image
  259. *images;
  260. /*
  261. Stream input image.
  262. */
  263. FireImageStack(MagickFalse,MagickFalse,pend);
  264. filename=argv[i];
  265. if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
  266. filename=argv[++i];
  267. (void) CopyMagickString(image_info->filename,filename,MagickPathExtent);
  268. images=StreamImage(image_info,stream_info,exception);
  269. status&=(images != (Image *) NULL) &&
  270. (exception->severity < ErrorException);
  271. if (images == (Image *) NULL)
  272. continue;
  273. AppendImageStack(images);
  274. continue;
  275. }
  276. pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
  277. switch (*(option+1))
  278. {
  279. case 'a':
  280. {
  281. if (LocaleCompare("authenticate",option+1) == 0)
  282. {
  283. if (*option == '+')
  284. break;
  285. i++;
  286. if (i == (ssize_t) argc)
  287. ThrowStreamException(OptionError,"MissingArgument",option);
  288. break;
  289. }
  290. ThrowStreamException(OptionError,"UnrecognizedOption",option)
  291. }
  292. case 'c':
  293. {
  294. if (LocaleCompare("cache",option+1) == 0)
  295. {
  296. if (*option == '+')
  297. break;
  298. i++;
  299. if (i == (ssize_t) argc)
  300. ThrowStreamException(OptionError,"MissingArgument",option);
  301. if (IsGeometry(argv[i]) == MagickFalse)
  302. ThrowStreamInvalidArgumentException(option,argv[i]);
  303. break;
  304. }
  305. if (LocaleCompare("channel",option+1) == 0)
  306. {
  307. ssize_t
  308. channel;
  309. if (*option == '+')
  310. break;
  311. i++;
  312. if (i == (ssize_t) argc)
  313. ThrowStreamException(OptionError,"MissingArgument",option);
  314. channel=ParseChannelOption(argv[i]);
  315. if (channel < 0)
  316. ThrowStreamException(OptionError,"UnrecognizedChannelType",
  317. argv[i]);
  318. break;
  319. }
  320. if (LocaleCompare("colorspace",option+1) == 0)
  321. {
  322. ssize_t
  323. colorspace;
  324. if (*option == '+')
  325. break;
  326. i++;
  327. if (i == (ssize_t) argc)
  328. ThrowStreamException(OptionError,"MissingArgument",option);
  329. colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
  330. argv[i]);
  331. if (colorspace < 0)
  332. ThrowStreamException(OptionError,"UnrecognizedColorspace",
  333. argv[i]);
  334. break;
  335. }
  336. if (LocaleCompare("compress",option+1) == 0)
  337. {
  338. ssize_t
  339. compress;
  340. if (*option == '+')
  341. break;
  342. i++;
  343. if (i == (ssize_t) argc)
  344. ThrowStreamException(OptionError,"MissingArgument",option);
  345. compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
  346. argv[i]);
  347. if (compress < 0)
  348. ThrowStreamException(OptionError,"UnrecognizedImageCompression",
  349. argv[i]);
  350. break;
  351. }
  352. if (LocaleCompare("concurrent",option+1) == 0)
  353. break;
  354. ThrowStreamException(OptionError,"UnrecognizedOption",option)
  355. }
  356. case 'd':
  357. {
  358. if (LocaleCompare("debug",option+1) == 0)
  359. {
  360. ssize_t
  361. event;
  362. if (*option == '+')
  363. break;
  364. i++;
  365. if (i == (ssize_t) argc)
  366. ThrowStreamException(OptionError,"MissingArgument",option);
  367. event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
  368. if (event < 0)
  369. ThrowStreamException(OptionError,"UnrecognizedEventType",argv[i]);
  370. (void) SetLogEventMask(argv[i]);
  371. break;
  372. }
  373. if (LocaleCompare("define",option+1) == 0)
  374. {
  375. i++;
  376. if (i == (ssize_t) argc)
  377. ThrowStreamException(OptionError,"MissingArgument",option);
  378. if (*option == '+')
  379. {
  380. const char
  381. *define;
  382. define=GetImageOption(image_info,argv[i]);
  383. if (define == (const char *) NULL)
  384. ThrowStreamException(OptionError,"NoSuchOption",argv[i]);
  385. break;
  386. }
  387. break;
  388. }
  389. if (LocaleCompare("density",option+1) == 0)
  390. {
  391. if (*option == '+')
  392. break;
  393. i++;
  394. if (i == (ssize_t) argc)
  395. ThrowStreamException(OptionError,"MissingArgument",option);
  396. if (IsGeometry(argv[i]) == MagickFalse)
  397. ThrowStreamInvalidArgumentException(option,argv[i]);
  398. break;
  399. }
  400. if (LocaleCompare("depth",option+1) == 0)
  401. {
  402. if (*option == '+')
  403. break;
  404. i++;
  405. if (i == (ssize_t) argc)
  406. ThrowStreamException(OptionError,"MissingArgument",option);
  407. if (IsGeometry(argv[i]) == MagickFalse)
  408. ThrowStreamInvalidArgumentException(option,argv[i]);
  409. break;
  410. }
  411. if (LocaleCompare("duration",option+1) == 0)
  412. {
  413. if (*option == '+')
  414. break;
  415. i++;
  416. if (i == (ssize_t) argc)
  417. ThrowStreamException(OptionError,"MissingArgument",option);
  418. if (IsGeometry(argv[i]) == MagickFalse)
  419. ThrowStreamInvalidArgumentException(option,argv[i]);
  420. break;
  421. }
  422. ThrowStreamException(OptionError,"UnrecognizedOption",option)
  423. }
  424. case 'e':
  425. {
  426. if (LocaleCompare("extract",option+1) == 0)
  427. {
  428. if (*option == '+')
  429. break;
  430. i++;
  431. if (i == (ssize_t) argc)
  432. ThrowStreamException(OptionError,"MissingArgument",option);
  433. if (IsGeometry(argv[i]) == MagickFalse)
  434. ThrowStreamInvalidArgumentException(option,argv[i]);
  435. break;
  436. }
  437. ThrowStreamException(OptionError,"UnrecognizedOption",option)
  438. }
  439. case 'h':
  440. {
  441. if ((LocaleCompare("help",option+1) == 0) ||
  442. (LocaleCompare("-help",option+1) == 0))
  443. return(StreamUsage());
  444. ThrowStreamException(OptionError,"UnrecognizedOption",option)
  445. }
  446. case 'i':
  447. {
  448. if (LocaleCompare("identify",option+1) == 0)
  449. break;
  450. if (LocaleCompare("interlace",option+1) == 0)
  451. {
  452. ssize_t
  453. interlace;
  454. if (*option == '+')
  455. break;
  456. i++;
  457. if (i == (ssize_t) argc)
  458. ThrowStreamException(OptionError,"MissingArgument",option);
  459. interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
  460. argv[i]);
  461. if (interlace < 0)
  462. ThrowStreamException(OptionError,"UnrecognizedInterlaceType",
  463. argv[i]);
  464. break;
  465. }
  466. if (LocaleCompare("interpolate",option+1) == 0)
  467. {
  468. ssize_t
  469. interpolate;
  470. if (*option == '+')
  471. break;
  472. i++;
  473. if (i == (ssize_t) argc)
  474. ThrowStreamException(OptionError,"MissingArgument",option);
  475. interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
  476. argv[i]);
  477. if (interpolate < 0)
  478. ThrowStreamException(OptionError,"UnrecognizedInterpolateMethod",
  479. argv[i]);
  480. break;
  481. }
  482. ThrowStreamException(OptionError,"UnrecognizedOption",option)
  483. }
  484. case 'l':
  485. {
  486. if (LocaleCompare("limit",option+1) == 0)
  487. {
  488. char
  489. *p;
  490. double
  491. value;
  492. ssize_t
  493. resource;
  494. if (*option == '+')
  495. break;
  496. i++;
  497. if (i == (ssize_t) argc)
  498. ThrowStreamException(OptionError,"MissingArgument",option);
  499. resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
  500. argv[i]);
  501. if (resource < 0)
  502. ThrowStreamException(OptionError,"UnrecognizedResourceType",
  503. argv[i]);
  504. i++;
  505. if (i == (ssize_t) argc)
  506. ThrowStreamException(OptionError,"MissingArgument",option);
  507. value=StringToDouble(argv[i],&p);
  508. (void) value;
  509. if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
  510. ThrowStreamInvalidArgumentException(option,argv[i]);
  511. break;
  512. }
  513. if (LocaleCompare("list",option+1) == 0)
  514. {
  515. ssize_t
  516. list;
  517. if (*option == '+')
  518. break;
  519. i++;
  520. if (i == (ssize_t) argc)
  521. ThrowStreamException(OptionError,"MissingArgument",option);
  522. list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
  523. if (list < 0)
  524. ThrowStreamException(OptionError,"UnrecognizedListType",argv[i]);
  525. status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
  526. argv+j,exception);
  527. DestroyStream();
  528. return(status == 0 ? MagickFalse : MagickTrue);
  529. }
  530. if (LocaleCompare("log",option+1) == 0)
  531. {
  532. if (*option == '+')
  533. break;
  534. i++;
  535. if ((i == (ssize_t) argc) || (strchr(argv[i],'%') == (char *) NULL))
  536. ThrowStreamException(OptionError,"MissingArgument",option);
  537. break;
  538. }
  539. ThrowStreamException(OptionError,"UnrecognizedOption",option)
  540. }
  541. case 'm':
  542. {
  543. if (LocaleCompare("map",option+1) == 0)
  544. {
  545. (void) CopyMagickString(argv[i]+1,"san",MagickPathExtent);
  546. if (*option == '+')
  547. break;
  548. i++;
  549. SetStreamInfoMap(stream_info,argv[i]);
  550. break;
  551. }
  552. if (LocaleCompare("monitor",option+1) == 0)
  553. break;
  554. ThrowStreamException(OptionError,"UnrecognizedOption",option)
  555. }
  556. case 'q':
  557. {
  558. if (LocaleCompare("quantize",option+1) == 0)
  559. {
  560. ssize_t
  561. colorspace;
  562. if (*option == '+')
  563. break;
  564. i++;
  565. if (i == (ssize_t) argc)
  566. ThrowStreamException(OptionError,"MissingArgument",option);
  567. colorspace=ParseCommandOption(MagickColorspaceOptions,
  568. MagickFalse,argv[i]);
  569. if (colorspace < 0)
  570. ThrowStreamException(OptionError,"UnrecognizedColorspace",
  571. argv[i]);
  572. break;
  573. }
  574. if (LocaleCompare("quiet",option+1) == 0)
  575. break;
  576. ThrowStreamException(OptionError,"UnrecognizedOption",option)
  577. }
  578. case 'r':
  579. {
  580. if (LocaleCompare("regard-warnings",option+1) == 0)
  581. break;
  582. if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
  583. {
  584. respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
  585. break;
  586. }
  587. ThrowStreamException(OptionError,"UnrecognizedOption",option)
  588. }
  589. case 's':
  590. {
  591. if (LocaleCompare("sampling-factor",option+1) == 0)
  592. {
  593. if (*option == '+')
  594. break;
  595. i++;
  596. if (i == (ssize_t) argc)
  597. ThrowStreamException(OptionError,"MissingArgument",option);
  598. if (IsGeometry(argv[i]) == MagickFalse)
  599. ThrowStreamInvalidArgumentException(option,argv[i]);
  600. break;
  601. }
  602. if (LocaleCompare("seed",option+1) == 0)
  603. {
  604. if (*option == '+')
  605. break;
  606. i++;
  607. if (i == (ssize_t) argc)
  608. ThrowStreamException(OptionError,"MissingArgument",option);
  609. if (IsGeometry(argv[i]) == MagickFalse)
  610. ThrowStreamInvalidArgumentException(option,argv[i]);
  611. break;
  612. }
  613. if (LocaleCompare("set",option+1) == 0)
  614. {
  615. i++;
  616. if (i == (ssize_t) argc)
  617. ThrowStreamException(OptionError,"MissingArgument",option);
  618. if (*option == '+')
  619. break;
  620. i++;
  621. if (i == (ssize_t) argc)
  622. ThrowStreamException(OptionError,"MissingArgument",option);
  623. break;
  624. }
  625. if (LocaleCompare("size",option+1) == 0)
  626. {
  627. if (*option == '+')
  628. break;
  629. i++;
  630. if (i == (ssize_t) argc)
  631. ThrowStreamException(OptionError,"MissingArgument",option);
  632. if (IsGeometry(argv[i]) == MagickFalse)
  633. ThrowStreamInvalidArgumentException(option,argv[i]);
  634. break;
  635. }
  636. if (LocaleCompare("storage-type",option+1) == 0)
  637. {
  638. ssize_t
  639. type;
  640. if (*option == '+')
  641. break;
  642. i++;
  643. if (i == (ssize_t) argc)
  644. ThrowStreamException(OptionError,"MissingArgument",option);
  645. type=ParseCommandOption(MagickStorageOptions,MagickFalse,argv[i]);
  646. if (type < 0)
  647. ThrowStreamException(OptionError,"UnrecognizedStorageType",
  648. argv[i]);
  649. SetStreamInfoStorageType(stream_info,(StorageType) type);
  650. break;
  651. }
  652. if (LocaleCompare("synchronize",option+1) == 0)
  653. break;
  654. ThrowStreamException(OptionError,"UnrecognizedOption",option)
  655. }
  656. case 't':
  657. {
  658. if (LocaleCompare("taint",option+1) == 0)
  659. break;
  660. if (LocaleCompare("transparent-color",option+1) == 0)
  661. {
  662. if (*option == '+')
  663. break;
  664. i++;
  665. if (i == (ssize_t) argc)
  666. ThrowStreamException(OptionError,"MissingArgument",option);
  667. break;
  668. }
  669. ThrowStreamException(OptionError,"UnrecognizedOption",option)
  670. }
  671. case 'v':
  672. {
  673. if (LocaleCompare("verbose",option+1) == 0)
  674. break;
  675. if ((LocaleCompare("version",option+1) == 0) ||
  676. (LocaleCompare("-version",option+1) == 0))
  677. {
  678. ListMagickVersion(stdout);
  679. break;
  680. }
  681. if (LocaleCompare("virtual-pixel",option+1) == 0)
  682. {
  683. ssize_t
  684. method;
  685. if (*option == '+')
  686. break;
  687. i++;
  688. if (i == (ssize_t) argc)
  689. ThrowStreamException(OptionError,"MissingArgument",option);
  690. method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
  691. argv[i]);
  692. if (method < 0)
  693. ThrowStreamException(OptionError,"UnrecognizedVirtualPixelMethod",
  694. argv[i]);
  695. break;
  696. }
  697. ThrowStreamException(OptionError,"UnrecognizedOption",option)
  698. }
  699. case '?':
  700. break;
  701. default:
  702. ThrowStreamException(OptionError,"UnrecognizedOption",option)
  703. }
  704. fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
  705. FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
  706. if (fire != MagickFalse)
  707. FireImageStack(MagickFalse,MagickTrue,MagickTrue);
  708. }
  709. if (k != 0)
  710. ThrowStreamException(OptionError,"UnbalancedParenthesis",argv[i]);
  711. if (i-- != (ssize_t) (argc-1))
  712. ThrowStreamException(OptionError,"MissingAnImageFilename",argv[i]);
  713. if (image == (Image *) NULL)
  714. ThrowStreamException(OptionError,"MissingAnImageFilename",argv[i]);
  715. FinalizeImageSettings(image_info,image,MagickTrue);
  716. if (image == (Image *) NULL)
  717. ThrowStreamException(OptionError,"MissingAnImageFilename",argv[i]);
  718. DestroyStream();
  719. return(status != 0 ? MagickTrue : MagickFalse);
  720. }