Convert Bitmap to Thumbnail

I want to create a thumbnail image from C #. How to do it?

+3
source share
1 answer

The Image class has a GetThumbnailImage . Usage example:

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 create a miniature version of the fb.png file of 20x40px size and save it in thumb.png.

+9
source

Source: https://habr.com/ru/post/1782425/


All Articles