Project Descriptionhigh quality image resizing and cropping
this library is used in http://prodinner.codeplex.com (asp.net mvc sample application) for creating thumbnails
ASP.net Awesome has been released, see it on the new website: www.aspnetawesome.com
cropping
Image img = Imager.Crop(sourceImage, new Rectangle(x, y, width, height));
resizing
Image img = Imager.Resize(sourceImage, newWidth, maxHeight, onlyResizeIfWider);
save
Imager.Save(path, img, Imager.GetEncoderInfo("image/gif"));
//image/gif is the MIME type for gif
save as jpeg
Imager.SaveJpeg(path, img);
example of usage in asp.net mvc with jquery plugin jcrop
[OutputCache(Location = OutputCacheLocation.None)]
public ActionResult Crop(CropDisplay cropDisplay)
{
return View(cropDisplay);
}
[HttpPost]
[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");
}