public string Execute(FileItem item, string infile, string dest, ValuePairEnumerator configData)
        {
            var conf = new PixelBinningViewModel(configData);
            dest = Path.Combine(Path.GetDirectoryName(dest), Path.GetFileNameWithoutExtension(dest) + ".jpg");

            using (MagickImage image = new MagickImage(infile))
            {
                int newx = image.Width/(conf.SelectedMode + 2);
                int newy = image.Height / (conf.SelectedMode + 2);
                int cropx = newx * (conf.SelectedMode + 2);
                int cropy = newy * (conf.SelectedMode + 2);
                if (cropx != image.Width || cropy != image.Height)
                    image.Crop(cropx, cropy, Gravity.Center);
                image.FilterType = FilterType.Box;
                image.Resize(newx,newy);
                image.Format = MagickFormat.Jpeg;
                image.Write(dest);
            }
            return dest;
        }
Beispiel #2
0
        public string Execute(FileItem item, string infile, string dest, ValuePairEnumerator configData)
        {
            var conf = new PixelBinningViewModel(configData);

            dest = Path.Combine(Path.GetDirectoryName(dest), Path.GetFileNameWithoutExtension(dest) + ".jpg");

            using (MagickImage image = new MagickImage(infile))
            {
                int newx  = image.Width / (conf.SelectedMode + 2);
                int newy  = image.Height / (conf.SelectedMode + 2);
                int cropx = newx * (conf.SelectedMode + 2);
                int cropy = newy * (conf.SelectedMode + 2);
                if (cropx != image.Width || cropy != image.Height)
                {
                    image.Crop(cropx, cropy, Gravity.Center);
                }
                image.FilterType = FilterType.Box;
                image.Resize(newx, newy);
                image.Format = MagickFormat.Jpeg;
                image.Write(dest);
            }
            return(dest);
        }