Project Description
high quality image resizing and cropping

source code here:

used in ( mvc sample app) for creating thumbnails
using Omu.Drawing;


Image img = Imager.Crop(sourceImage, new Rectangle(x, y, width, height));


Image img = Imager.Resize(sourceImage, newWidth, maxHeight, onlyResizeIfWider);


Imager.Save(path, img, Imager.GetEncoderInfo("image/gif"));
//image/gif is the MIME type for gif

save as jpeg

Imager.SaveJpeg(path, img);

put on canvas

the image remains the same size, and it is placed in the middle of the new canvas
Imager.PutOnWhiteCanvas(img, width, height))
// or
Imager.PutOnCanvas(img, width, height, Color.White))

example of usage in mvc with jquery plugin jcrop

        [OutputCache(Location = OutputCacheLocation.None)]
        public ActionResult Crop(CropDisplay cropDisplay)
            return View(cropDisplay);

        [OutputCache(Location = OutputCacheLocation.None)]
        public ActionResult Crop(int x, int y, int w, int h)
            using (var image = Image.FromFile(@ConfigurationManager.AppSettings["storagePath"] + @"\Temp\" + User.Identity.Name + ".jpg"))
                var img = Imager.Crop(image, new Rectangle(x, y, w, h));
                var resized = Imager.Resize(img, 200, 150, true);
                Imager.SaveJpeg(@ConfigurationManager.AppSettings["storagePath"] + @"\Profile\" + User.Identity.Name + ".jpg", resized);
            return RedirectToAction("Index");

Last edited May 10, 2016 at 8:17 AM by o, version 13