From 52ad9e9f4dcd7d29b2c78aede281621c33df1ce1 Mon Sep 17 00:00:00 2001 From: cristy Date: Fri, 8 Feb 2013 23:23:29 +0000 Subject: [PATCH] --- MagickWand/convert.c | 36 +++++++++++ MagickWand/mogrify.c | 131 +++++++++++++++++++++++++++++++++++++++++ MagickWand/operation.c | 26 ++++++++ 3 files changed, 193 insertions(+) diff --git a/MagickWand/convert.c b/MagickWand/convert.c index 33f25203e..c5cf6f4d4 100644 --- a/MagickWand/convert.c +++ b/MagickWand/convert.c @@ -233,6 +233,9 @@ static MagickBooleanType ConvertUsage(void) " improve contrast by 'stretching with saturation'", "-liquid-rescale geometry", " rescale image with seam-carving", + "-median geometry apply a median filter to the image", + "-mode geometry make each pixel the 'predominant color' of the", + " neighborhood", "-modulate value vary the brightness, saturation, and hue", "-monochrome transform image to black and white", "-morphology method kernel", @@ -718,6 +721,8 @@ WandExport MagickBooleanType ConvertImageCommand(ImageInfo *image_info, break; if (LocaleCompare("auto-orient",option+1) == 0) break; + if (LocaleCompare("average",option+1) == 0) + break; ThrowConvertException(OptionError,"UnrecognizedOption",option) } case 'b': @@ -1967,6 +1972,32 @@ WandExport MagickBooleanType ConvertImageCommand(ImageInfo *image_info, ThrowConvertException(OptionError,"MissingArgument",option); break; } + if (LocaleCompare("maximum",option+1) == 0) + break; + if (LocaleCompare("median",option+1) == 0) + { + if (*option == '+') + break; + i++; + if (i == (ssize_t) (argc-1)) + ThrowConvertException(OptionError,"MissingArgument",option); + if (IsGeometry(argv[i]) == MagickFalse) + ThrowConvertInvalidArgumentException(option,argv[i]); + break; + } + if (LocaleCompare("minimum",option+1) == 0) + break; + if (LocaleCompare("mode",option+1) == 0) + { + if (*option == '+') + break; + i++; + if (i == (ssize_t) (argc-1)) + ThrowConvertException(OptionError,"MissingArgument",option); + if (IsGeometry(argv[i]) == MagickFalse) + ThrowConvertInvalidArgumentException(option,argv[i]); + break; + } if (LocaleCompare("modulate",option+1) == 0) { if (*option == '+') @@ -2715,6 +2746,11 @@ WandExport MagickBooleanType ConvertImageCommand(ImageInfo *image_info, argv[i]); break; } + if (LocaleCompare("support",option+1) == 0) + { + i++; /* deprecated */ + break; + } if (LocaleCompare("swap",option+1) == 0) { if (*option == '+') diff --git a/MagickWand/mogrify.c b/MagickWand/mogrify.c index cf921c9bf..081dec967 100644 --- a/MagickWand/mogrify.c +++ b/MagickWand/mogrify.c @@ -2035,6 +2035,38 @@ WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, mask=DestroyImage(mask); break; } + if (LocaleCompare("matte",option+1) == 0) + { + (void) SetImageAlphaChannel(*image,(*option == '-') ? + SetAlphaChannel : DeactivateAlphaChannel,exception); + break; + } + if (LocaleCompare("median",option+1) == 0) + { + /* + Median filter image. + */ + (void) SyncImageSettings(mogrify_info,*image,exception); + flags=ParseGeometry(argv[i+1],&geometry_info); + if ((flags & SigmaValue) == 0) + geometry_info.sigma=geometry_info.rho; + mogrify_image=StatisticImage(*image,MedianStatistic,(size_t) + geometry_info.rho,(size_t) geometry_info.sigma,exception); + break; + } + if (LocaleCompare("mode",option+1) == 0) + { + /* + Mode image. + */ + (void) SyncImageSettings(mogrify_info,*image,exception); + flags=ParseGeometry(argv[i+1],&geometry_info); + if ((flags & SigmaValue) == 0) + geometry_info.sigma=geometry_info.rho; + mogrify_image=StatisticImage(*image,ModeStatistic,(size_t) + geometry_info.rho,(size_t) geometry_info.sigma,exception); + break; + } if (LocaleCompare("modulate",option+1) == 0) { (void) SyncImageSettings(mogrify_info,*image,exception); @@ -3275,6 +3307,7 @@ static MagickBooleanType MogrifyUsage(void) " improve contrast by 'stretching with saturation'", "-liquid-rescale geometry", " rescale image with seam-carving", + "-median geometry apply a median filter to the image", "-mode geometry make each pixel the 'predominant color' of the", " neighborhood", "-modulate value vary the brightness, saturation, and hue", @@ -3811,6 +3844,8 @@ WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info, break; if (LocaleCompare("auto-orient",option+1) == 0) break; + if (LocaleCompare("average",option+1) == 0) + break; ThrowMogrifyException(OptionError,"UnrecognizedOption",option) } case 'b': @@ -4984,6 +5019,8 @@ WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info, ThrowMogrifyException(OptionError,"MissingArgument",option); break; } + if (LocaleCompare("matte",option+1) == 0) + break; if (LocaleCompare("mattecolor",option+1) == 0) { if (*option == '+') @@ -4993,6 +5030,10 @@ WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info, ThrowMogrifyException(OptionError,"MissingArgument",option); break; } + if (LocaleCompare("maximum",option+1) == 0) + break; + if (LocaleCompare("minimum",option+1) == 0) + break; if (LocaleCompare("modulate",option+1) == 0) { if (*option == '+') @@ -5004,6 +5045,28 @@ WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info, ThrowMogrifyInvalidArgumentException(option,argv[i]); break; } + if (LocaleCompare("median",option+1) == 0) + { + if (*option == '+') + break; + i++; + if (i == (ssize_t) argc) + ThrowMogrifyException(OptionError,"MissingArgument",option); + if (IsGeometry(argv[i]) == MagickFalse) + ThrowMogrifyInvalidArgumentException(option,argv[i]); + break; + } + if (LocaleCompare("mode",option+1) == 0) + { + if (*option == '+') + break; + i++; + if (i == (ssize_t) argc) + ThrowMogrifyException(OptionError,"MissingArgument",option); + if (IsGeometry(argv[i]) == MagickFalse) + ThrowMogrifyInvalidArgumentException(option,argv[i]); + break; + } if (LocaleCompare("monitor",option+1) == 0) break; if (LocaleCompare("monochrome",option+1) == 0) @@ -6728,6 +6791,16 @@ WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info, } case 'm': { + if (LocaleCompare("matte",option+1) == 0) + { + if (*option == '+') + { + (void) SetImageOption(image_info,option+1,"false"); + break; + } + (void) SetImageOption(image_info,option+1,"true"); + break; + } if (LocaleCompare("mattecolor",option+1) == 0) { if (*option == '+') @@ -7248,6 +7321,26 @@ WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info, *images=append_image; break; } + if (LocaleCompare("average",option+1) == 0) + { + Image + *average_image; + + /* + Average an image sequence (deprecated). + */ + (void) SyncImagesSettings(mogrify_info,*images,exception); + average_image=EvaluateImages(*images,MeanEvaluateOperator, + exception); + if (average_image == (Image *) NULL) + { + status=MagickFalse; + break; + } + *images=DestroyImageList(*images); + *images=average_image; + break; + } break; } case 'c': @@ -7823,6 +7916,44 @@ WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info, i++; break; } + if (LocaleCompare("maximum",option+1) == 0) + { + Image + *maximum_image; + + /* + Maximum image sequence (deprecated). + */ + (void) SyncImagesSettings(mogrify_info,*images,exception); + maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception); + if (maximum_image == (Image *) NULL) + { + status=MagickFalse; + break; + } + *images=DestroyImageList(*images); + *images=maximum_image; + break; + } + if (LocaleCompare("minimum",option+1) == 0) + { + Image + *minimum_image; + + /* + Minimum image sequence (deprecated). + */ + (void) SyncImagesSettings(mogrify_info,*images,exception); + minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception); + if (minimum_image == (Image *) NULL) + { + status=MagickFalse; + break; + } + *images=DestroyImageList(*images); + *images=minimum_image; + break; + } if (LocaleCompare("morph",option+1) == 0) { Image diff --git a/MagickWand/operation.c b/MagickWand/operation.c index c6b7d9997..17db95c12 100644 --- a/MagickWand/operation.c +++ b/MagickWand/operation.c @@ -2643,6 +2643,26 @@ static void CLISimpleOperatorImage(MagickCLI *cli_wand, mask=DestroyImage(mask); break; } + if (LocaleCompare("matte",option+1) == 0) + { + CLIWandWarnReplaced(IfNormalOp?"-alpha Set":"-alpha Off"); + (void) SetImageAlphaChannel(_image,IfNormalOp ? SetAlphaChannel : + DeactivateAlphaChannel, _exception); + break; + } + if (LocaleCompare("median",option+1) == 0) + { + CLIWandWarnReplaced("-statistic Median"); + CLISimpleOperatorImage(cli_wand,"-statistic","Median",arg1); + break; + } + if (LocaleCompare("mode",option+1) == 0) + { + /* FUTURE: note this is also a special "montage" option */ + CLIWandWarnReplaced("-statistic Mode"); + CLISimpleOperatorImage(cli_wand,"-statistic","Mode",arg1); + break; + } if (LocaleCompare("modulate",option+1) == 0) { if (IfMagickFalse(IsGeometry(arg1))) @@ -3536,6 +3556,12 @@ WandExport void CLIListOperatorImages(MagickCLI *cli_wand, new_images=AppendImages(_images,normal_op,_exception); break; } + if (LocaleCompare("average",option+1) == 0) + { + CLIWandWarnReplaced("-evaluate-sequence Mean"); + CLIListOperatorImages(cli_wand,"-evaluate-sequence","Mean",NULL); + break; + } CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); } case 'c': -- 2.40.0