public static void ResizeFile(string source, string destination, int width, int height) {
using (var bitmap = new Bitmap(width, height))
using (var graphics = Graphics.FromImage(bitmap)) {
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
using (var image = Image.FromFile(source)) {
var k = Math.Min((double)image.Width / width, (double)image.Height / height);
var nw = (float)(image.Width / k);
var nh = (float)(image.Height / k);
graphics.DrawImage(image, (nw - width) / 2f, (nh - height) / 2f, nw, nh);
}
bitmap.Save(destination, ImageFormat.Png);
}
}