Hello everybody I would like to ask how can I resize an image without losing quality?
Here is my controller method
var fileName = DateTime.Now.ToString("MM.dd.yyyy HH.mm.ss") + Path.GetFileName(file.FileName);
var path = Path.Combine(Server.MapPath("~/uploads/"), fileName);
file.SaveAs(path);
System.Drawing.Image img = System.Drawing.Image.FromFile(Server.MapPath("~/uploads/") + fileName);
System.Drawing.Image thumb = img.GetThumbnailImage(97, 114, null, IntPtr.Zero);
img.Dispose();
thumb.Save(Server.MapPath("~/uploads/") + fileName);
There are some really good image resizing libraries out there – I would use one of those. I’m using ImageResizing on one of my projects and the results have been pretty good. Bertrand LeRoy has done some benchmarking of some of the main libraries, which you might find useful.