I want to generate a thumbnail from an image in C#. How do I do that?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With