private static void TransformImage(int width, int height, string path, Image image,
float scale)
{
Bitmap thump = new Bitmap(width, height);
Graphics graphics = Graphics.FromImage(thump);
Matrix transform = new Matrix();
transform.Scale(scale, scale, MatrixOrder.Append);
graphics.SetClip(new Rectangle(0, 0, width, height));
graphics.Transform = transform;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.DrawImage(image, 0, 0, image.Width, image.Height);
ImageCodecInfo[] Info = ImageCodecInfo.GetImageEncoders();
EncoderParameters Params = new EncoderParameters(1);
Params.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 100L);
thump.Save(path, Info[1], Params);
thump.Dispose();
graphics.Dispose();
}