Exemplo n.º 1
0
        public IActionResult Rotate(RedactionRequest redact)
        {
            var source = Path.Combine(Path.Combine(_env.WebRootPath, "images"), _img);
            var dest   = Path.Combine(Path.Combine(Path.Combine(_env.WebRootPath, "images"), "canvas-buffer"), "x.jpg");

            using (var image = Image.Load(source))
            {
                image.Mutate(x => x.Rotate(RotateMode.Rotate90));
                image.Save(source);

                image.Mutate(x => x
                             .Resize(image.Width / _scale, image.Height / _scale));

                image.Save(dest);
            }

            return(Ok());
        }
Exemplo n.º 2
0
        public IActionResult Index(RedactionRequest redact)
        {
            var source = Path.Combine(Path.Combine(_env.WebRootPath, "images"), _img);
            var dest   = Path.Combine(Path.Combine(Path.Combine(_env.WebRootPath, "images"), "canvas-buffer"), "x.jpg");

            // Resize and save a copy
            using (var image = Image.Load(source))
            {
                foreach (var r in redact.Redactions)
                {
                    image.Mutate(x => x
                                 //.Pixelate(_blurSize, new SixLabors.Primitives.Rectangle((int)r.X * _scale, (int)r.Y * _scale, (int)r.W * _scale, (int)r.H * _scale))
                                 .BoxBlur(_blurSize, new SixLabors.Primitives.Rectangle((int)r.X * _scale, (int)r.Y * _scale, (int)r.W * _scale, (int)r.H * _scale))
                                 );
                }
                image.Save(source);

                image.Mutate(x => x
                             .Resize(image.Width / _scale, image.Height / _scale));
                image.Save(dest);
            }

            return(Ok());
        }