A thumbnail is a small sized image. Creating a thumbnail using .NET is extremely simple. In this article, we will explore how to create a thumbnail image and display the thumbnail in our application. Follow these steps:
- First Add Windows Form In your Application. After that Drag & drop 1 Label , 1 TextBox , 2 Buttons , 1 PictureBox & 1 OpenfileDialogBox Controls From Toolbox. Now change all the names of the controls that mention belowed.
- After renaming All the controls On the ‘btnOpen’ click display the File Open dialog box and accept the selected .jpg file in the ‘txtPath’ textbox.
- Next, on the ‘btnGenerate’ click, add the following code:
The code creates an Image object from the image supplied in the textbox. Using the Image.GetThumbnailImage(), the code then creates a thumbnail image with a size of 100*100.
The Image.GetThumbnailImage() takes in four arguments :
Run the application, select the image and click on the Generate button. The preview will be similar to the image displayed below : 🙂