PageRenderTime 55ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 1ms

/plugins/ImageMagick-6.3.2/wand/mogrify.c

https://bitbucket.org/sisko/operation-caribou
C | 6683 lines | 5890 code | 235 blank | 558 comment | 2356 complexity | 86a449ee3127915f3d6a0808fc5a0ece MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, LGPL-2.1

Large files files are truncated, but you can click here to view the full file

  1. /*
  2. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  3. % %
  4. % %
  5. % %
  6. % M M OOO GGGGG RRRR IIIII FFFFF Y Y %
  7. % MM MM O O G R R I F Y Y %
  8. % M M M O O G GGG RRRR I FFF Y %
  9. % M M O O G G R R I F Y %
  10. % M M OOO GGGG R R IIIII F Y %
  11. % %
  12. % %
  13. % ImageMagick Module Methods %
  14. % %
  15. % Software Design %
  16. % John Cristy %
  17. % March 2000 %
  18. % %
  19. % %
  20. % Copyright 1999-2006 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. %
  37. %
  38. */
  39. /*
  40. Include declarations.
  41. */
  42. #include "wand/studio.h"
  43. #include "wand/MagickWand.h"
  44. #include "wand/mogrify-private.h"
  45. /*
  46. Define declarations.
  47. */
  48. #define ThrowWandFatalException(severity,tag,context) \
  49. { \
  50. ExceptionInfo \
  51. exception; \
  52. \
  53. GetExceptionInfo(&exception); \
  54. (void) ThrowMagickException(&exception,GetMagickModule(),severity,tag, \
  55. "`%s'",context); \
  56. CatchException(&exception); \
  57. (void) DestroyExceptionInfo(&exception); \
  58. }
  59. #define UndefinedCompressionQuality 0UL
  60. /*
  61. Constant declaration.
  62. */
  63. static const char
  64. *BackgroundColor = "#fff", /* white */
  65. *BorderColor = "#dfdfdf", /* gray */
  66. *MatteColor = "#bdbdbd"; /* gray */
  67. /*
  68. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  69. % %
  70. % %
  71. % %
  72. + M o g r i f y I m a g e %
  73. % %
  74. % %
  75. % %
  76. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  77. %
  78. % MogrifyImage() applies image processing options to an image as prescribed
  79. % by command line options.
  80. %
  81. % The format of the MogrifyImage method is:
  82. %
  83. % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
  84. % const char **argv,Image **image)
  85. %
  86. % A description of each parameter follows:
  87. %
  88. % o image_info: The image info..
  89. %
  90. % o argc: Specifies a pointer to an integer describing the number of
  91. % elements in the argument vector.
  92. %
  93. % o argv: Specifies a pointer to a text array containing the command line
  94. % arguments.
  95. %
  96. % o image: The image.
  97. %
  98. % o exception: Return any errors or warnings in this structure.
  99. %
  100. */
  101. static inline long MagickMax(const long x,const long y)
  102. {
  103. if (x > y)
  104. return(x);
  105. return(y);
  106. }
  107. static MagickBooleanType MonitorProgress(const char *tag,
  108. const MagickOffsetType quantum,const MagickSizeType span,
  109. void *wand_unused(client_data))
  110. {
  111. char
  112. message[MaxTextExtent];
  113. const char
  114. *locale_message;
  115. if (span < 2)
  116. return(MagickTrue);
  117. (void) FormatMagickString(message,MaxTextExtent,"Monitor/%s",tag);
  118. locale_message=GetLocaleMessage(message);
  119. if (locale_message == message)
  120. locale_message=tag;
  121. (void) fprintf(stdout,"%s: %02ld%%\r",locale_message,(long)
  122. (100L*quantum/(span-1)));
  123. if ((MagickSizeType) quantum == (span-1))
  124. (void) fprintf(stdout,"\n");
  125. (void) fflush(stdout);
  126. return(MagickTrue);
  127. }
  128. WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
  129. const char **argv,Image **image,ExceptionInfo *exception)
  130. {
  131. ChannelType
  132. channel;
  133. const char
  134. *format,
  135. *option;
  136. DrawInfo
  137. *draw_info;
  138. GeometryInfo
  139. geometry_info;
  140. Image
  141. *region_image;
  142. long
  143. count;
  144. MagickBooleanType
  145. status;
  146. MagickPixelPacket
  147. fill;
  148. MagickStatusType
  149. flags;
  150. QuantizeInfo
  151. *quantize_info;
  152. RectangleInfo
  153. geometry,
  154. region_geometry;
  155. register long
  156. i;
  157. /*
  158. Initialize method variables.
  159. */
  160. assert(image_info != (const ImageInfo *) NULL);
  161. assert(image_info->signature == MagickSignature);
  162. assert(image != (Image **) NULL);
  163. assert((*image)->signature == MagickSignature);
  164. if ((*image)->debug != MagickFalse)
  165. (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
  166. if (argc < 0)
  167. return(MagickTrue);
  168. for (i=0; i < (long) argc; i++)
  169. if (strlen(argv[i]) > (MaxTextExtent/2-1))
  170. ThrowWandFatalException(OptionFatalError,"OptionLengthExceedsLimit",
  171. argv[i]);
  172. draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
  173. quantize_info=AcquireQuantizeInfo(image_info);
  174. SetGeometryInfo(&geometry_info);
  175. channel=image_info->channel;
  176. GetMagickPixelPacket(*image,&fill);
  177. SetMagickPixelPacket(&(*image)->background_color,(IndexPacket *) NULL,&fill);
  178. format=GetImageOption(image_info,"format");
  179. SetGeometry(*image,&region_geometry);
  180. region_image=NewImageList();
  181. /*
  182. Transmogrify the image.
  183. */
  184. for (i=0; i < (long) argc; i++)
  185. {
  186. option=argv[i];
  187. if (IsMagickOption(option) == MagickFalse)
  188. continue;
  189. count=MagickMax(ParseMagickOption(MagickCommandOptions,MagickFalse,option),
  190. 0L);
  191. if ((i+count) >= argc)
  192. break;
  193. status=MogrifyImageInfo(image_info,count+1,argv+i,exception);
  194. switch (*(option+1))
  195. {
  196. case 'a':
  197. {
  198. if (LocaleCompare("adaptive-blur",option+1) == 0)
  199. {
  200. Image
  201. *blur_image;
  202. /*
  203. Blur image.
  204. */
  205. flags=ParseGeometry(argv[i+1],&geometry_info);
  206. if ((flags & SigmaValue) == 0)
  207. geometry_info.sigma=1.0;
  208. blur_image=AdaptiveBlurImageChannel(*image,channel,
  209. geometry_info.rho,geometry_info.sigma,exception);
  210. if (blur_image == (Image *) NULL)
  211. break;
  212. InheritException(&blur_image->exception,exception);
  213. *image=DestroyImage(*image);
  214. *image=blur_image;
  215. break;
  216. }
  217. if (LocaleCompare("adaptive-resize",option+1) == 0)
  218. {
  219. Image
  220. *resize_image;
  221. /*
  222. Resize image.
  223. */
  224. (void) ParseSizeGeometry(*image,argv[i+1],&geometry);
  225. resize_image=AdaptiveResizeImage(*image,geometry.width,
  226. geometry.height,exception);
  227. if (resize_image == (Image *) NULL)
  228. break;
  229. InheritException(&resize_image->exception,exception);
  230. *image=DestroyImage(*image);
  231. *image=resize_image;
  232. break;
  233. }
  234. if (LocaleCompare("adaptive-sharpen",option+1) == 0)
  235. {
  236. Image
  237. *sharp_image;
  238. /*
  239. Sharpen image.
  240. */
  241. flags=ParseGeometry(argv[i+1],&geometry_info);
  242. if ((flags & SigmaValue) == 0)
  243. geometry_info.sigma=1.0;
  244. sharp_image=AdaptiveSharpenImageChannel(*image,channel,
  245. geometry_info.rho,geometry_info.sigma,exception);
  246. if (sharp_image == (Image *) NULL)
  247. break;
  248. InheritException(&sharp_image->exception,exception);
  249. *image=DestroyImage(*image);
  250. *image=sharp_image;
  251. break;
  252. }
  253. if (LocaleCompare("affine",option+1) == 0)
  254. {
  255. /*
  256. Affine matrix.
  257. */
  258. if (*option == '+')
  259. {
  260. GetAffineMatrix(&draw_info->affine);
  261. break;
  262. }
  263. (void) ParseAffineGeometry(argv[i+1],&draw_info->affine);
  264. break;
  265. }
  266. if (LocaleCompare("annotate",option+1) == 0)
  267. {
  268. char
  269. geometry[MaxTextExtent];
  270. /*
  271. Annotate image.
  272. */
  273. SetGeometryInfo(&geometry_info);
  274. flags=ParseGeometry(argv[i+1],&geometry_info);
  275. if ((flags & SigmaValue) == 0)
  276. geometry_info.sigma=geometry_info.rho;
  277. (void) CloneString(&draw_info->text,InterpretImageProperties(
  278. image_info,*image,argv[i+2]));
  279. (void) FormatMagickString(geometry,MaxTextExtent,"%+f%+f",
  280. geometry_info.xi,geometry_info.psi);
  281. (void) CloneString(&draw_info->geometry,geometry);
  282. draw_info->affine.sx=cos(DegreesToRadians(
  283. fmod(geometry_info.rho,360.0)));
  284. draw_info->affine.rx=sin(DegreesToRadians(
  285. fmod(geometry_info.rho,360.0)));
  286. draw_info->affine.ry=(-sin(DegreesToRadians(
  287. fmod(geometry_info.sigma,360.0))));
  288. draw_info->affine.sy=cos(DegreesToRadians(
  289. fmod(geometry_info.sigma,360.0)));
  290. (void) AnnotateImage(*image,draw_info);
  291. break;
  292. }
  293. if (LocaleCompare("antialias",option+1) == 0)
  294. {
  295. draw_info->stroke_antialias=(*option == '-') ? MagickTrue :
  296. MagickFalse;
  297. draw_info->text_antialias=(*option == '-') ? MagickTrue :
  298. MagickFalse;
  299. break;
  300. }
  301. if (LocaleCompare("auto-orient",option+1) == 0)
  302. {
  303. Image
  304. *orient_image;
  305. orient_image=NewImageList();
  306. switch ((*image)->orientation)
  307. {
  308. case TopRightOrientation:
  309. {
  310. orient_image=FlopImage(*image,exception);
  311. break;
  312. }
  313. case BottomRightOrientation:
  314. {
  315. orient_image=RotateImage(*image,180.0,exception);
  316. break;
  317. }
  318. case BottomLeftOrientation:
  319. {
  320. orient_image=FlipImage(*image,exception);
  321. break;
  322. }
  323. case LeftTopOrientation:
  324. {
  325. orient_image=TransposeImage(*image,exception);
  326. break;
  327. }
  328. case RightTopOrientation:
  329. {
  330. orient_image=RotateImage(*image,90.0,exception);
  331. break;
  332. }
  333. case RightBottomOrientation:
  334. {
  335. orient_image=TransverseImage(*image,exception);
  336. break;
  337. }
  338. case LeftBottomOrientation:
  339. {
  340. orient_image=RotateImage(*image,270.0,exception);
  341. break;
  342. }
  343. default:
  344. break;
  345. }
  346. if (orient_image == (Image *) NULL)
  347. break;
  348. InheritException(&orient_image->exception,exception);
  349. *image=DestroyImage(*image);
  350. *image=orient_image;
  351. break;
  352. }
  353. break;
  354. }
  355. case 'b':
  356. {
  357. if (LocaleCompare("background",option+1) == 0)
  358. {
  359. if (*option == '+')
  360. {
  361. (void) QueryColorDatabase(BackgroundColor,
  362. &(*image)->background_color,exception);
  363. break;
  364. }
  365. (void) QueryColorDatabase(argv[i+1],&(*image)->background_color,
  366. exception);
  367. break;
  368. }
  369. if (LocaleCompare("bias",option+1) == 0)
  370. {
  371. (*image)->bias=StringToDouble(argv[i+1],QuantumRange);
  372. break;
  373. }
  374. if (LocaleCompare("black-threshold",option+1) == 0)
  375. {
  376. /*
  377. Threshold black image.
  378. */
  379. (void) BlackThresholdImage(*image,argv[i+1]);
  380. break;
  381. }
  382. if (LocaleCompare("black-point-compensation",option+1) == 0)
  383. {
  384. (*image)->black_point_compensation=(*option == '-') ? MagickTrue :
  385. MagickFalse;
  386. break;
  387. }
  388. if (LocaleCompare("blue-primary",option+1) == 0)
  389. {
  390. /*
  391. Blue chromaticity primary point.
  392. */
  393. if (*option == '+')
  394. {
  395. (*image)->chromaticity.blue_primary.x=0.0;
  396. (*image)->chromaticity.blue_primary.y=0.0;
  397. break;
  398. }
  399. flags=ParseGeometry(argv[i+1],&geometry_info);
  400. (*image)->chromaticity.blue_primary.x=geometry_info.rho;
  401. (*image)->chromaticity.blue_primary.y=geometry_info.sigma;
  402. if ((flags & SigmaValue) == 0)
  403. (*image)->chromaticity.blue_primary.y=
  404. (*image)->chromaticity.blue_primary.x;
  405. break;
  406. }
  407. if (LocaleCompare("blur",option+1) == 0)
  408. {
  409. Image
  410. *blur_image;
  411. /*
  412. Gaussian blur image.
  413. */
  414. flags=ParseGeometry(argv[i+1],&geometry_info);
  415. if ((flags & SigmaValue) == 0)
  416. geometry_info.sigma=1.0;
  417. blur_image=BlurImageChannel(*image,channel,
  418. geometry_info.rho,geometry_info.sigma,exception);
  419. if (blur_image == (Image *) NULL)
  420. break;
  421. InheritException(&blur_image->exception,exception);
  422. *image=DestroyImage(*image);
  423. *image=blur_image;
  424. break;
  425. }
  426. if (LocaleCompare("border",option+1) == 0)
  427. {
  428. Image
  429. *border_image;
  430. /*
  431. Surround image with a border of solid color.
  432. */
  433. flags=ParsePageGeometry(*image,argv[i+1],&geometry);
  434. if ((flags & SigmaValue) == 0)
  435. geometry.height=geometry.width;
  436. border_image=BorderImage(*image,&geometry,exception);
  437. if (border_image == (Image *) NULL)
  438. break;
  439. InheritException(&border_image->exception,exception);
  440. *image=DestroyImage(*image);
  441. *image=border_image;
  442. break;
  443. }
  444. if (LocaleCompare("bordercolor",option+1) == 0)
  445. {
  446. if (*option == '+')
  447. {
  448. (void) QueryColorDatabase(BorderColor,&(*image)->border_color,
  449. exception);
  450. draw_info->border_color=(*image)->border_color;
  451. break;
  452. }
  453. (void) QueryColorDatabase(argv[i+1],&(*image)->border_color,
  454. exception);
  455. draw_info->border_color=(*image)->border_color;
  456. break;
  457. }
  458. if (LocaleCompare("box",option+1) == 0)
  459. {
  460. (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor,
  461. exception);
  462. break;
  463. }
  464. break;
  465. }
  466. case 'c':
  467. {
  468. if (LocaleCompare("cache",option+1) == 0)
  469. {
  470. unsigned long
  471. limit;
  472. limit=(~0UL);
  473. if (LocaleCompare("unlimited",argv[i+1]) != 0)
  474. limit=(unsigned long) atol(argv[i+1]);
  475. (void) SetMagickResourceLimit(MemoryResource,limit);
  476. (void) SetMagickResourceLimit(MapResource,2*limit);
  477. break;
  478. }
  479. if (LocaleCompare("channel",option+1) == 0)
  480. {
  481. if (*option == '+')
  482. {
  483. channel=DefaultChannels;
  484. break;
  485. }
  486. channel=(ChannelType) ParseChannelOption(argv[i+1]);
  487. break;
  488. }
  489. if (LocaleCompare("charcoal",option+1) == 0)
  490. {
  491. Image
  492. *charcoal_image;
  493. /*
  494. Charcoal image.
  495. */
  496. flags=ParseGeometry(argv[i+1],&geometry_info);
  497. if ((flags & SigmaValue) == 0)
  498. geometry_info.sigma=1.0;
  499. charcoal_image=CharcoalImage(*image,geometry_info.rho,
  500. geometry_info.sigma,exception);
  501. if (charcoal_image == (Image *) NULL)
  502. break;
  503. InheritException(&charcoal_image->exception,exception);
  504. *image=DestroyImage(*image);
  505. *image=charcoal_image;
  506. break;
  507. }
  508. if (LocaleCompare("chop",option+1) == 0)
  509. {
  510. Image
  511. *chop_image;
  512. /*
  513. Chop the image.
  514. */
  515. (void) ParseGravityGeometry(*image,argv[i+1],&geometry);
  516. chop_image=ChopImage(*image,&geometry,exception);
  517. if (chop_image == (Image *) NULL)
  518. break;
  519. InheritException(&chop_image->exception,exception);
  520. *image=DestroyImage(*image);
  521. *image=chop_image;
  522. break;
  523. }
  524. if (LocaleCompare("clip",option+1) == 0)
  525. {
  526. if (*option == '+')
  527. {
  528. (void) SetImageClipMask(*image,(Image *) NULL);
  529. break;
  530. }
  531. (void) ClipImage(*image);
  532. break;
  533. }
  534. if (LocaleCompare("clip-mask",option+1) == 0)
  535. {
  536. Image
  537. *mask;
  538. ImageInfo
  539. *mask_info;
  540. long
  541. y;
  542. register long
  543. x;
  544. register PixelPacket
  545. *q;
  546. if (*option == '+')
  547. {
  548. /*
  549. Remove a mask.
  550. */
  551. (void) SetImageMask(*image,(Image *) NULL);
  552. break;
  553. }
  554. /*
  555. Set the image mask.
  556. */
  557. mask_info=CloneImageInfo(image_info);
  558. (void) CopyMagickString(mask_info->filename,argv[i+1],
  559. MaxTextExtent);
  560. mask=ReadImage(mask_info,exception);
  561. CatchException(exception);
  562. mask_info=DestroyImageInfo(mask_info);
  563. if (mask == (Image *) NULL)
  564. break;
  565. for (y=0; y < (long) mask->rows; y++)
  566. {
  567. q=GetImagePixels(mask,0,y,mask->columns,1);
  568. if (q == (PixelPacket *) NULL)
  569. break;
  570. for (x=0; x < (long) mask->columns; x++)
  571. {
  572. if (mask->matte == MagickFalse)
  573. q->opacity=PixelIntensityToQuantum(q);
  574. q->red=q->opacity;
  575. q->green=q->opacity;
  576. q->blue=q->opacity;
  577. q++;
  578. }
  579. if (SyncImagePixels(mask) == MagickFalse)
  580. break;
  581. }
  582. if (SetImageStorageClass(mask,DirectClass) == MagickFalse)
  583. return(MagickFalse);
  584. mask->matte=MagickTrue;
  585. (void) SetImageClipMask(*image,mask);
  586. break;
  587. }
  588. if (LocaleCompare("clip-path",option+1) == 0)
  589. {
  590. (void) ClipPathImage(*image,argv[i+1],
  591. *option == '-' ? MagickTrue : MagickFalse);
  592. break;
  593. }
  594. if (LocaleCompare("colorize",option+1) == 0)
  595. {
  596. Image
  597. *colorize_image;
  598. /*
  599. Colorize the image.
  600. */
  601. colorize_image=ColorizeImage(*image,argv[i+1],draw_info->fill,
  602. exception);
  603. if (colorize_image == (Image *) NULL)
  604. break;
  605. InheritException(&colorize_image->exception,exception);
  606. *image=DestroyImage(*image);
  607. *image=colorize_image;
  608. break;
  609. }
  610. if (LocaleCompare("colors",option+1) == 0)
  611. {
  612. /*
  613. Reduce the number of colors in the image.
  614. */
  615. quantize_info->number_colors=(unsigned long) atol(argv[i+1]);
  616. if (quantize_info->number_colors == 0)
  617. break;
  618. if (((*image)->storage_class == DirectClass) ||
  619. (*image)->colors > quantize_info->number_colors)
  620. (void) QuantizeImage(quantize_info,*image);
  621. else
  622. CompressImageColormap(*image);
  623. break;
  624. }
  625. if (LocaleCompare("colorspace",option+1) == 0)
  626. {
  627. ColorspaceType
  628. colorspace;
  629. if (*option == '+')
  630. {
  631. (void) SetImageColorspace(*image,RGBColorspace);
  632. break;
  633. }
  634. colorspace=(ColorspaceType) ParseMagickOption(
  635. MagickColorspaceOptions,MagickFalse,argv[i+1]);
  636. (void) SetImageColorspace(*image,colorspace);
  637. break;
  638. }
  639. if (LocaleCompare("compose",option+1) == 0)
  640. {
  641. if (*option == '+')
  642. {
  643. (*image)->compose=OverCompositeOp;
  644. break;
  645. }
  646. (*image)->compose=(CompositeOperator) ParseMagickOption(
  647. MagickCompositeOptions,MagickFalse,argv[i+1]);
  648. break;
  649. }
  650. if (LocaleCompare("compress",option+1) == 0)
  651. {
  652. if (*option == '+')
  653. {
  654. (*image)->compression=UndefinedCompression;
  655. break;
  656. }
  657. (*image)->compression=(CompressionType) ParseMagickOption(
  658. MagickCompressionOptions,MagickFalse,argv[i+1]);
  659. break;
  660. }
  661. if (LocaleCompare("contrast",option+1) == 0)
  662. {
  663. (void) ContrastImage(*image,(*option == '-') ? MagickTrue :
  664. MagickFalse);
  665. break;
  666. }
  667. if (LocaleCompare("contrast-stretch",option+1) == 0)
  668. {
  669. GeometryInfo
  670. geometry_info;
  671. MagickRealType
  672. black_point,
  673. white_point;
  674. MagickStatusType
  675. flags;
  676. /*
  677. Parse levels.
  678. */
  679. flags=ParseGeometry(argv[i+1],&geometry_info);
  680. black_point=geometry_info.rho;
  681. white_point=(MagickRealType) (*image)->columns*(*image)->rows;
  682. if ((flags & SigmaValue) != 0)
  683. white_point=geometry_info.sigma;
  684. if ((flags & PercentValue) != 0)
  685. {
  686. black_point*=(MagickRealType) (*image)->columns*
  687. (*image)->rows/100.0f;
  688. white_point*=(MagickRealType) (*image)->columns*
  689. (*image)->rows/100.0f;
  690. }
  691. if ((flags & SigmaValue) == 0)
  692. white_point=(MagickRealType) (*image)->columns*(*image)->rows-
  693. black_point;
  694. (void) ContrastStretchImageChannel(*image,channel,black_point,
  695. white_point);
  696. break;
  697. }
  698. if (LocaleCompare("convolve",option+1) == 0)
  699. {
  700. char
  701. *p,
  702. token[MaxTextExtent];
  703. double
  704. *kernel;
  705. Image
  706. *convolve_image;
  707. register long
  708. x;
  709. unsigned long
  710. order;
  711. /*
  712. Convolve image.
  713. */
  714. p=(char *) argv[i+1];
  715. for (x=0; *p != '\0'; x++)
  716. {
  717. GetMagickToken(p,&p,token);
  718. if (*token == ',')
  719. GetMagickToken(p,&p,token);
  720. }
  721. order=(unsigned long) sqrt((double) x+1.0);
  722. kernel=(double *) AcquireMagickMemory(order*order*sizeof(*kernel));
  723. if (kernel == (double *) NULL)
  724. ThrowWandFatalException(ResourceLimitFatalError,
  725. "MemoryAllocationFailed",(*image)->filename);
  726. p=(char *) argv[i+1];
  727. for (x=0; *p != '\0'; x++)
  728. {
  729. GetMagickToken(p,&p,token);
  730. if (*token == ',')
  731. GetMagickToken(p,&p,token);
  732. kernel[x]=atof(token);
  733. }
  734. for ( ; x < (long) (order*order); x++)
  735. kernel[x]=0.0;
  736. convolve_image=ConvolveImageChannel(*image,channel,order,kernel,
  737. exception);
  738. kernel=(double *) RelinquishMagickMemory(kernel);
  739. if (convolve_image == (Image *) NULL)
  740. break;
  741. InheritException(&convolve_image->exception,exception);
  742. *image=DestroyImage(*image);
  743. *image=convolve_image;
  744. break;
  745. }
  746. if (LocaleCompare("crop",option+1) == 0)
  747. {
  748. if (*option == '+')
  749. break;
  750. break;
  751. }
  752. if (LocaleCompare("cycle",option+1) == 0)
  753. {
  754. /*
  755. Cycle an image colormap.
  756. */
  757. (void) CycleColormapImage(*image,atoi(argv[i+1]));
  758. break;
  759. }
  760. break;
  761. }
  762. case 'd':
  763. {
  764. if (LocaleCompare("debug",option+1) == 0)
  765. {
  766. if (*option == '+')
  767. {
  768. (void) SetLogEventMask("none");
  769. break;
  770. }
  771. (void) SetLogEventMask(argv[i+1]);
  772. break;
  773. }
  774. if (LocaleCompare("density",option+1) == 0)
  775. {
  776. GeometryInfo
  777. geometry_info;
  778. /*
  779. Set image density.
  780. */
  781. (void) CloneString(&draw_info->density,argv[i+1]);
  782. flags=ParseGeometry(argv[i+1],&geometry_info);
  783. (*image)->x_resolution=geometry_info.rho;
  784. (*image)->y_resolution=geometry_info.sigma;
  785. if ((flags & SigmaValue) == 0)
  786. (*image)->y_resolution=(*image)->x_resolution;
  787. break;
  788. }
  789. if (LocaleCompare("despeckle",option+1) == 0)
  790. {
  791. Image
  792. *despeckle_image;
  793. /*
  794. Reduce the speckles within an image.
  795. */
  796. despeckle_image=DespeckleImage(*image,exception);
  797. if (despeckle_image == (Image *) NULL)
  798. break;
  799. InheritException(&despeckle_image->exception,exception);
  800. *image=DestroyImage(*image);
  801. *image=despeckle_image;
  802. break;
  803. }
  804. if (LocaleCompare("display",option+1) == 0)
  805. {
  806. (void) CloneString(&draw_info->server_name,argv[i+1]);
  807. break;
  808. }
  809. if (LocaleCompare("dither",option+1) == 0)
  810. {
  811. quantize_info->dither=(*option == '-') ? MagickTrue : MagickFalse;
  812. break;
  813. }
  814. if (LocaleCompare("draw",option+1) == 0)
  815. {
  816. /*
  817. Draw image.
  818. */
  819. (void) CloneString(&draw_info->primitive,argv[i+1]);
  820. (void) DrawImage(*image,draw_info);
  821. break;
  822. }
  823. break;
  824. }
  825. case 'e':
  826. {
  827. if (LocaleCompare("edge",option+1) == 0)
  828. {
  829. Image
  830. *edge_image;
  831. /*
  832. Enhance edges in the image.
  833. */
  834. flags=ParseGeometry(argv[i+1],&geometry_info);
  835. if ((flags & SigmaValue) == 0)
  836. geometry_info.sigma=1.0;
  837. edge_image=EdgeImage(*image,geometry_info.rho,exception);
  838. if (edge_image == (Image *) NULL)
  839. break;
  840. InheritException(&edge_image->exception,exception);
  841. *image=DestroyImage(*image);
  842. *image=edge_image;
  843. break;
  844. }
  845. if (LocaleCompare("emboss",option+1) == 0)
  846. {
  847. Image
  848. *emboss_image;
  849. /*
  850. Gaussian embossen image.
  851. */
  852. flags=ParseGeometry(argv[i+1],&geometry_info);
  853. if ((flags & SigmaValue) == 0)
  854. geometry_info.sigma=1.0;
  855. emboss_image=EmbossImage(*image,geometry_info.rho,
  856. geometry_info.sigma,exception);
  857. if (emboss_image == (Image *) NULL)
  858. break;
  859. InheritException(&emboss_image->exception,exception);
  860. *image=DestroyImage(*image);
  861. *image=emboss_image;
  862. break;
  863. }
  864. if (LocaleCompare("encoding",option+1) == 0)
  865. {
  866. (void) CloneString(&draw_info->encoding,argv[i+1]);
  867. break;
  868. }
  869. if (LocaleCompare("endian",option+1) == 0)
  870. {
  871. if (*option == '+')
  872. {
  873. (*image)->endian=LSBEndian;
  874. break;
  875. }
  876. (*image)->endian=(EndianType) ParseMagickOption(MagickEndianOptions,
  877. MagickFalse,argv[i+1]);
  878. break;
  879. }
  880. if (LocaleCompare("enhance",option+1) == 0)
  881. {
  882. Image
  883. *enhance_image;
  884. /*
  885. Enhance image.
  886. */
  887. enhance_image=EnhanceImage(*image,exception);
  888. if (enhance_image == (Image *) NULL)
  889. break;
  890. InheritException(&enhance_image->exception,exception);
  891. *image=DestroyImage(*image);
  892. *image=enhance_image;
  893. break;
  894. }
  895. if (LocaleCompare("equalize",option+1) == 0)
  896. {
  897. /*
  898. Equalize image.
  899. */
  900. (void) EqualizeImage(*image);
  901. break;
  902. }
  903. if (LocaleCompare("evaluate",option+1) == 0)
  904. {
  905. double
  906. constant;
  907. MagickEvaluateOperator
  908. op;
  909. op=(MagickEvaluateOperator) ParseMagickOption(MagickEvaluateOptions,
  910. MagickFalse,argv[i+1]);
  911. constant=StringToDouble(argv[i+2],QuantumRange);
  912. (void) EvaluateImageChannel(*image,channel,op,constant,
  913. exception);
  914. break;
  915. }
  916. if (LocaleCompare("extent",option+1) == 0)
  917. {
  918. Image
  919. *extent_image;
  920. /*
  921. Set the image extent.
  922. */
  923. (void) ParseGravityGeometry(*image,argv[i+1],&geometry);
  924. extent_image=ExtentImage(*image,&geometry,exception);
  925. if (extent_image == (Image *) NULL)
  926. break;
  927. InheritException(&extent_image->exception,exception);
  928. *image=DestroyImage(*image);
  929. *image=extent_image;
  930. break;
  931. }
  932. break;
  933. }
  934. case 'f':
  935. {
  936. if (LocaleCompare("family",option+1) == 0)
  937. {
  938. if (*option == '+')
  939. draw_info->family=(char *) RelinquishMagickMemory(
  940. draw_info->family);
  941. else
  942. (void) CloneString(&draw_info->family,argv[i+1]);
  943. break;
  944. }
  945. if (LocaleCompare("fill",option+1) == 0)
  946. {
  947. ExceptionInfo
  948. *sans;
  949. if (*option == '+')
  950. {
  951. (void) QueryMagickColor("none",&fill,exception);
  952. (void) QueryColorDatabase("none",&draw_info->fill,exception);
  953. break;
  954. }
  955. sans=AcquireExceptionInfo();
  956. (void) QueryMagickColor(argv[i+1],&fill,sans);
  957. status=QueryColorDatabase(argv[i+1],&draw_info->fill,sans);
  958. sans=DestroyExceptionInfo(sans);
  959. if (status == MagickFalse)
  960. draw_info->fill_pattern=ReadImage(image_info,exception);
  961. break;
  962. }
  963. if (LocaleCompare("filter",option+1) == 0)
  964. {
  965. if (*option == '+')
  966. {
  967. (*image)->filter=UndefinedFilter;
  968. break;
  969. }
  970. (*image)->filter=(FilterTypes) ParseMagickOption(
  971. MagickFilterOptions,MagickFalse,argv[i+1]);
  972. break;
  973. }
  974. if (LocaleCompare("flip",option+1) == 0)
  975. {
  976. Image
  977. *flip_image;
  978. /*
  979. Flip image scanlines.
  980. */
  981. flip_image=FlipImage(*image,exception);
  982. if (flip_image == (Image *) NULL)
  983. break;
  984. InheritException(&flip_image->exception,exception);
  985. *image=DestroyImage(*image);
  986. *image=flip_image;
  987. break;
  988. }
  989. if (LocaleCompare("flop",option+1) == 0)
  990. {
  991. Image
  992. *flop_image;
  993. /*
  994. Flop image scanlines.
  995. */
  996. flop_image=FlopImage(*image,exception);
  997. if (flop_image == (Image *) NULL)
  998. break;
  999. InheritException(&flop_image->exception,exception);
  1000. *image=DestroyImage(*image);
  1001. *image=flop_image;
  1002. break;
  1003. }
  1004. if (LocaleCompare("floodfill",option+1) == 0)
  1005. {
  1006. PixelPacket
  1007. target;
  1008. /*
  1009. Floodfill image.
  1010. */
  1011. (void) ParsePageGeometry(*image,argv[i+1],&geometry);
  1012. (void) QueryColorDatabase(argv[i+2],&target,exception);
  1013. (void) ColorFloodfillImage(*image,draw_info,target,geometry.x,
  1014. geometry.y,FloodfillMethod);
  1015. break;
  1016. }
  1017. if (LocaleCompare("font",option+1) == 0)
  1018. {
  1019. if (*option == '+')
  1020. {
  1021. draw_info->font=(char *) RelinquishMagickMemory(
  1022. draw_info->font);
  1023. break;
  1024. }
  1025. (void) CloneString(&draw_info->font,argv[i+1]);
  1026. break;
  1027. }
  1028. if (LocaleCompare("format",option+1) == 0)
  1029. {
  1030. format=argv[i+1];
  1031. break;
  1032. }
  1033. if (LocaleCompare("frame",option+1) == 0)
  1034. {
  1035. FrameInfo
  1036. frame_info;
  1037. Image
  1038. *frame_image;
  1039. /*
  1040. Surround image with an ornamental border.
  1041. */
  1042. (void) ParsePageGeometry(*image,argv[i+1],&geometry);
  1043. frame_info.width=geometry.width;
  1044. frame_info.height=geometry.height;
  1045. frame_info.outer_bevel=geometry.x;
  1046. frame_info.inner_bevel=geometry.y;
  1047. frame_info.x=(long) frame_info.width;
  1048. frame_info.y=(long) frame_info.height;
  1049. frame_info.width=(*image)->columns+2*frame_info.width;
  1050. frame_info.height=(*image)->rows+2*frame_info.height;
  1051. frame_image=FrameImage(*image,&frame_info,exception);
  1052. if (frame_image == (Image *) NULL)
  1053. break;
  1054. InheritException(&frame_image->exception,exception);
  1055. *image=DestroyImage(*image);
  1056. *image=frame_image;
  1057. break;
  1058. }
  1059. if (LocaleCompare("fuzz",option+1) == 0)
  1060. {
  1061. if (*option == '+')
  1062. {
  1063. (*image)->fuzz=0.0;
  1064. break;
  1065. }
  1066. (*image)->fuzz=StringToDouble(argv[i+1],QuantumRange+1.0);
  1067. break;
  1068. }
  1069. break;
  1070. }
  1071. case 'g':
  1072. {
  1073. if (LocaleCompare("gamma",option+1) == 0)
  1074. {
  1075. if (*option == '+')
  1076. (*image)->gamma=atof(argv[i+1]);
  1077. else
  1078. {
  1079. if (strchr(argv[i+1],',') != (char *) NULL)
  1080. (void) GammaImage(*image,argv[i+1]);
  1081. else
  1082. (void) GammaImageChannel(*image,channel,
  1083. atof(argv[i+1]));
  1084. }
  1085. break;
  1086. }
  1087. if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
  1088. (LocaleCompare("gaussian",option+1) == 0))
  1089. {
  1090. Image
  1091. *gaussian_image;
  1092. /*
  1093. Gaussian blur image.
  1094. */
  1095. flags=ParseGeometry(argv[i+1],&geometry_info);
  1096. if ((flags & SigmaValue) == 0)
  1097. geometry_info.sigma=1.0;
  1098. gaussian_image=GaussianBlurImageChannel(*image,channel,
  1099. geometry_info.rho,geometry_info.sigma,exception);
  1100. if (gaussian_image == (Image *) NULL)
  1101. break;
  1102. InheritException(&gaussian_image->exception,exception);
  1103. *image=DestroyImage(*image);
  1104. *image=gaussian_image;
  1105. break;
  1106. }
  1107. if (LocaleCompare("geometry",option+1) == 0)
  1108. {
  1109. if (*option == '+')
  1110. {
  1111. if ((*image)->geometry != (char *) NULL)
  1112. (*image)->geometry=(char *) RelinquishMagickMemory(
  1113. (*image)->geometry);
  1114. break;
  1115. }
  1116. (void) CloneString(&(*image)->geometry,argv[i+1]);
  1117. flags=ParseSizeGeometry(*image,argv[i+1],&geometry);
  1118. if (((flags & XValue) == 0) && ((flags & YValue) == 0))
  1119. {
  1120. Image
  1121. *zoom_image;
  1122. /*
  1123. Resize image.
  1124. */
  1125. zoom_image=ZoomImage(*image,geometry.width,geometry.height,
  1126. exception);
  1127. if (zoom_image == (Image *) NULL)
  1128. break;
  1129. InheritException(&zoom_image->exception,exception);
  1130. *image=DestroyImage(*image);
  1131. *image=zoom_image;
  1132. }
  1133. break;
  1134. }
  1135. if (LocaleCompare("gravity",option+1) == 0)
  1136. {
  1137. if (*option == '+')
  1138. (*image)->gravity=UndefinedGravity;
  1139. else
  1140. (*image)->gravity=(GravityType) ParseMagickOption(
  1141. MagickGravityOptions,MagickFalse,argv[i+1]);
  1142. draw_info->gravity=(*image)->gravity;
  1143. break;
  1144. }
  1145. if (LocaleCompare("green-primary",option+1) == 0)
  1146. {
  1147. /*
  1148. Green chromaticity primary point.
  1149. */
  1150. if (*option == '+')
  1151. {
  1152. (*image)->chromaticity.green_primary.x=0.0;
  1153. (*image)->chromaticity.green_primary.y=0.0;
  1154. break;
  1155. }
  1156. flags=ParseGeometry(argv[i+1],&geometry_info);
  1157. (*image)->chromaticity.green_primary.x=geometry_info.rho;
  1158. (*image)->chromaticity.green_primary.y=geometry_info.sigma;
  1159. if ((flags & SigmaValue) == 0)
  1160. (*image)->chromaticity.green_primary.y=
  1161. (*image)->chromaticity.green_primary.x;
  1162. break;
  1163. }
  1164. break;
  1165. }
  1166. case 'i':
  1167. {
  1168. if (LocaleCompare("identify",option+1) == 0)
  1169. {
  1170. char
  1171. *text;
  1172. if (format == (char *) NULL)
  1173. {
  1174. (void) IdentifyImage(*image,stdout,image_info->verbose);
  1175. break;
  1176. }
  1177. text=InterpretImageProperties(image_info,*image,format);
  1178. if (text == (char *) NULL)
  1179. break;
  1180. (void) fputs(text,stdout);
  1181. (void) fputc('\n',stdout);
  1182. text=(char *) RelinquishMagickMemory(text);
  1183. break;
  1184. }
  1185. if (LocaleCompare("implode",option+1) == 0)
  1186. {
  1187. Image
  1188. *implode_image;
  1189. /*
  1190. Implode image.
  1191. */
  1192. (void) ParseGeometry(argv[i+1],&geometry_info);
  1193. implode_image=ImplodeImage(*image,geometry_info.rho,exception);
  1194. if (implode_image == (Image *) NULL)
  1195. break;
  1196. InheritException(&implode_image->exception,exception);
  1197. *image=DestroyImage(*image);
  1198. *image=implode_image;
  1199. break;
  1200. }
  1201. if (LocaleCompare("intent",option+1) == 0)
  1202. {
  1203. if (*option == '+')
  1204. {
  1205. (*image)->rendering_intent=UndefinedIntent;
  1206. break;
  1207. }
  1208. (*image)->rendering_intent=(RenderingIntent) ParseMagickOption(
  1209. MagickIntentOptions,MagickFalse,argv[i+1]);
  1210. break;
  1211. }
  1212. if (LocaleCompare("interlace",option+1) == 0)
  1213. {
  1214. /*
  1215. Interlace method.
  1216. */
  1217. if (*option == '+')
  1218. {
  1219. (*image)->interlace=UndefinedInterlace;
  1220. break;
  1221. }
  1222. (*image)->interlace=(InterlaceType) ParseMagickOption(
  1223. MagickInterlaceOptions,MagickFalse,argv[i+1]);
  1224. break;
  1225. }
  1226. if (LocaleCompare("interpolate",option+1) == 0)
  1227. {
  1228. /*
  1229. Interpolate method.
  1230. */
  1231. if (*option == '+')
  1232. {
  1233. (*image)->interpolate=UndefinedInterpolatePixel;
  1234. break;
  1235. }
  1236. (*image)->interpolate=(InterpolatePixelMethod) ParseMagickOption(
  1237. MagickInterpolateOptions,MagickFalse,argv[i+1]);
  1238. break;
  1239. }
  1240. break;
  1241. }
  1242. case 'l':
  1243. {
  1244. if (LocaleCompare("lat",option+1) == 0)
  1245. {
  1246. Image
  1247. *threshold_image;
  1248. /*
  1249. Local adaptive threshold image.
  1250. */
  1251. flags=ParseGeometry(argv[i+1],&geometry_info);
  1252. if ((flags & PercentValue) != 0)
  1253. geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
  1254. threshold_image=AdaptiveThresholdImage(*image,(unsigned long)
  1255. geometry_info.rho,(unsigned long) geometry_info.sigma,
  1256. (long) geometry_info.xi,exception);
  1257. if (threshold_image == (Image *) NULL)
  1258. break;
  1259. InheritException(&threshold_image->exception,exception);
  1260. *image=DestroyImage(*image);
  1261. *image=threshold_image;
  1262. break;
  1263. }
  1264. if (LocaleCompare("level",option+1) == 0)
  1265. {
  1266. GeometryInfo
  1267. geometry_info;
  1268. MagickRealType
  1269. black_point,
  1270. gamma,
  1271. white_point;
  1272. MagickStatusType
  1273. flags;
  1274. /*
  1275. Parse levels.
  1276. */
  1277. flags=ParseGeometry(argv[i+1],&geometry_info);
  1278. black_point=geometry_info.rho;
  1279. white_point=(MagickRealType) QuantumRange;
  1280. if ((flags & SigmaValue) != 0)
  1281. white_point=geometry_info.sigma;
  1282. gamma=1.0;
  1283. if ((flags & XiValue) != 0)
  1284. gamma=geometry_info.xi;
  1285. if ((white_point <= 10.0) && (gamma > 10.0))
  1286. {
  1287. MagickRealType
  1288. swap;
  1289. swap=gamma;
  1290. gamma=white_point;
  1291. white_point=swap;
  1292. }
  1293. if ((flags & PercentValue) != 0)
  1294. {
  1295. black_point*=(MagickRealType) (QuantumRange/100.0);
  1296. white_point*=(MagickRealType) (QuantumRange/100.0);
  1297. }
  1298. if ((flags & SigmaValue) == 0)
  1299. white_point=(MagickRealType) QuantumRange-black_point;
  1300. (void) LevelImageChannel(*image,channel,black_point,white_point,
  1301. gamma);
  1302. break;
  1303. }
  1304. if (LocaleCompare("limit",option+1) == 0)
  1305. {
  1306. ResourceType
  1307. type;
  1308. unsigned long
  1309. limit;
  1310. if (*option == '+')
  1311. break;
  1312. type=(ResourceType) ParseMagickOption(MagickResourceOptions,
  1313. MagickFalse,argv[i+1]);
  1314. limit=(~0UL);
  1315. if (LocaleCompare("unlimited",argv[i+2]) != 0)
  1316. limit=(unsigned long) atol(argv[i+2]);
  1317. (void) SetMagickResourceLimit(type,limit);
  1318. break;
  1319. }
  1320. if (LocaleCompare("linear-stretch",option+1) == 0)
  1321. {
  1322. GeometryInfo
  1323. geometry_info;
  1324. MagickRealType
  1325. black_point,
  1326. white_point;
  1327. MagickStatusType
  1328. flags;
  1329. /*
  1330. Parse levels.
  1331. */
  1332. flags=ParseGeometry(argv[i+1],&geometry_info);
  1333. black_point=geometry_info.rho;
  1334. white_point=(MagickRealType) (*image)->columns*(*image)->rows;
  1335. if ((flags & SigmaValue) != 0)
  1336. white_point=geometry_info.sigma;
  1337. if ((flags & PercentValue) != 0)
  1338. {
  1339. black_point*=(MagickRealType) (*image)->columns*
  1340. (*image)->rows/100.0f;
  1341. white_point*=(MagickRealType) (*image)->columns*
  1342. (*image)->rows/100.0f;
  1343. }
  1344. if ((flags & SigmaValue) == 0)
  1345. white_point=(MagickRealType) (*image)->columns*(*image)->rows-
  1346. black_point;
  1347. (void) LinearStretchImage(*image,black_point,white_point);
  1348. break;
  1349. }
  1350. if (LocaleCompare("linewidth",option+1) == 0)
  1351. {
  1352. draw_info->stroke_width=atof(argv[i+1]);
  1353. break;
  1354. }
  1355. if (LocaleCompare("loop",option+1) == 0)
  1356. {
  1357. /*
  1358. Set image iterations.
  1359. */
  1360. (*image)->iterations=(unsigned long) atol(argv[i+1]);
  1361. break;
  1362. }
  1363. break;
  1364. }
  1365. case 'm':
  1366. {
  1367. if (LocaleCompare("map",option+1) == 0)
  1368. {
  1369. Image
  1370. *map_image;
  1371. ImageInfo
  1372. *map_info;
  1373. /*
  1374. Transform image colors to match this set of colors.
  1375. */
  1376. if (*option == '+')
  1377. break;
  1378. map_info=CloneImageInfo(image_info);
  1379. (void) CopyMagickString(map_info->filename,argv[i+1],
  1380. MaxTextExtent);
  1381. map_image=ReadImage(map_info,exception);
  1382. map_info=DestroyImageInfo(map_info);
  1383. CatchException(exception);
  1384. if (map_image == (Image *) NULL)
  1385. break;
  1386. (void) MapImage(*image,map_image,quantize_info->dither);
  1387. map_image=DestroyImage(map_image);
  1388. break;
  1389. }
  1390. if (LocaleCompare("mask",option+1) == 0)
  1391. {
  1392. Image
  1393. *mask;
  1394. ImageInfo
  1395. *mask_info;
  1396. if (*option == '+')
  1397. {
  1398. /*
  1399. Remove a mask.
  1400. */
  1401. (void) SetImageMask(*image,(Image *) NULL);
  1402. break;
  1403. }
  1404. /*
  1405. Set the image mask.
  1406. */
  1407. mask_info=CloneImageInfo(image_info);
  1408. (void) CopyMagickString(mask_info->filename,argv[i+1],
  1409. MaxTextExtent);
  1410. mask=ReadImage(mask_info,exception);
  1411. CatchException(exception);
  1412. mask_info=DestroyImageInfo(mask_info);
  1413. if (mask == (Image *) NULL)
  1414. break;
  1415. (void) SetImageMask(*image,mask);
  1416. break;
  1417. }
  1418. if (LocaleCompare("matte",option+1) == 0)
  1419. {
  1420. if (*option == '-')
  1421. if ((*image)->matte == MagickFalse)
  1422. (void) SetImageOpacity(*image,OpaqueOpacity);
  1423. (*image)->matte=(*option == '-') ? MagickTrue : MagickFalse;
  1424. break;
  1425. }
  1426. if (LocaleCompare("mattecolor",option+1) == 0)
  1427. {
  1428. if (*option == '+')
  1429. {
  1430. (void) QueryColorDatabase(MatteColor,&(*image)->matte_color,
  1431. exception);
  1432. break;
  1433. }
  1434. (void) QueryColorDatabase(argv[i+1],&(*image)->matte_color,
  1435. exception);
  1436. break;
  1437. }
  1438. if (LocaleCompare("median",option+1) == 0)
  1439. {
  1440. Image
  1441. *median_image;
  1442. /*
  1443. Median filter image.
  1444. */
  1445. (void) ParseGeometry(argv[i+1],&geometry_info);
  1446. median_image=MedianFilterImage(*image,geometry_info.rho,exception);
  1447. if (median_image == (Image *) NULL)
  1448. break;
  1449. InheritException(&median_image->exception,exception);
  1450. *image=DestroyImage(*image);
  1451. *image=median_image;
  1452. break;
  1453. }
  1454. if (LocaleCompare("modulate",option+1) == 0)
  1455. {
  1456. (void) ModulateImage(*image,argv[i+1]);
  1457. break;
  1458. }
  1459. if (LocaleCompare("monitor",option+1) == 0)
  1460. {
  1461. (void) SetImageProgressMonitor(*image,MonitorProgress,
  1462. (void *) NULL);
  1463. break;
  1464. }
  1465. if (LocaleCom

Large files files are truncated, but you can click here to view the full file