I'm trying to resize an image and save it with the following snippet code. It works fine but some images lose quality after the resize. When I checked, the original images looked fine and only the ones which were resized had a low quality. I don't know how I can improve the image quality while resizing it.
System.Drawing.Image NewImage = FullsizeImage.GetThumbnailImage(NewWidth, MaxHeight, null, IntPtr.Zero);
// Clear handle to original file so that we can overwrite it if necessary
FullsizeImage.Dispose();
// Save resized picture
//NewImage.Save(NewFile);
if (fileExtension.ToLower() == ".jpg" || fileExtension.ToLower() == ".jpeg")
{
NewImage.Save(NewFile, System.Drawing.Imaging.ImageFormat.Jpeg);
}
Please, help me. Thanks.