Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert Bitmap to Thumbnail

Tags:

c#

I want to generate a thumbnail from an image in C#. How do I do that?

like image 669
user496949 Avatar asked Dec 28 '22 03:12

user496949


1 Answers

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.

like image 140
alexn Avatar answered Jan 12 '23 15:01

alexn