I want to generate a thumbnail from an image in C#. How do I do that?
Asked
Active
Viewed 4,437 times
4
-
System.Drawing.Bitmap or a WPF image? – Dec 28 '10 at 10:14
-
input params, desired output type, anything? – naveen Dec 28 '10 at 10:18
-
3please supply more details including what you have tried already – David Heffernan Dec 28 '10 at 10:19
1 Answers
11
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.

alexn
- 57,867
- 14
- 111
- 145