Reputation: 86055
I want to generate a thumbnail from an image in C#. How do I do that?
Upvotes: 4
Views: 4619
Reputation: 58952
The Image class actually has a GetThumbnailImage method. Example usage:
var filename = "fb.png";
using(var image = Image.FromFile(filename))
{
using(var thumbnail = image.GetThumbnailImage(20/*width*/, 40/*height*/, null, IntPtr.Zero))
{
thumbnail.Save("thumb.png");
}
}
This will generate a 20x40px thumbnail version of fb.png and save it to thumb.png.
Upvotes: 11