Example #1
0
        public string Execute(FileItem item, string infile, string dest, ValuePairEnumerator configData)
        {
            var conf = new EnhanceViewModel(configData);

            dest = Path.Combine(Path.GetDirectoryName(dest), Path.GetFileNameWithoutExtension(dest) + ".jpg");
            using (MagickImage image = new MagickImage(infile))
            {
                if (conf.Normalize)
                {
                    image.Normalize();
                }
                if (conf.AutoGamma)
                {
                    image.AutoGamma();
                }
                image.BrightnessContrast(new Percentage(conf.Brightness), new Percentage(conf.Contrast));
                if (conf.SContrast > 0)
                {
                    image.SigmoidalContrast(true, conf.SContrast);
                }
                if (conf.Edge)
                {
                    image.AdaptiveSharpen();
                }
                if (conf.Sharpen > 0)
                {
                    image.UnsharpMask(1.5, 1.5, conf.Sharpen / 100.0, 0.2);
                }
                image.Format = MagickFormat.Jpeg;
                image.Write(dest);
            }
            return(dest);
        }
Example #2
0
            public void ShouldSharpenTheImage()
            {
                using (var image = new MagickImage(Files.MagickNETIconPNG))
                {
                    image.AdaptiveSharpen(10, 10);
#if Q8 || Q16
                    ColorAssert.Equal(new MagickColor("#a95ce07af952"), image, 56, 68);
#else
                    ColorAssert.Equal(new MagickColor("#a8a8dfdff8f8"), image, 56, 68);
#endif
                }
            }
Example #3
0
            public void ShouldUseTheCorrectDefaultValuesWithChannels()
            {
                using (var imageA = new MagickImage(Files.MagickNETIconPNG))
                {
                    using (var imageB = imageA.Clone())
                    {
                        imageA.AdaptiveSharpen(Channels.Red);
                        imageB.AdaptiveSharpen(0.0, 1.0, Channels.Red);

                        var distortion = imageA.Compare(imageB, ErrorMetric.RootMeanSquared);
                        Assert.Equal(0.0, distortion);
                    }
                }
            }