Create Thumbnail on the fly by simple step

Dear All,

 Many times we require thumbnail image on the fly. ASP.Net provides an easy way by which we can create thumbnail.

I am showing basic steps by which we can create thumbnail. provides “System.Drawing.Image “namespace which having property “GetThumbnailImage” by which we can get Thumbnail image. It’s a simplest way to get a thumbnail. Below is the code written in VB.NET by which we upload an image, save image & create thumbnail and save thumbnail with thumbnail prefix.

Protected Sub Unnamed1_Click(ByVal sender As Object, ByVal e As EventArgs)


 If Me.FileUpload1.FileName.Trim <> String.Empty AndAlso Me.FileUpload1.FileContent.Length > 0 Then

Dim strUploadPath As String = Server.MapPath(“images”)

Dim strFileName As String = Me.FileUpload1.FileName FileUpload1.SaveAs(strUploadPath & “\” & strFileName)

 Dim img1 As System.Drawing.Image = System.Drawing.Image.FromFile(strUploadPath & “\” & strFileName)

Dim thumbNail As System.Drawing.Image = img1.GetThumbnailImage(100, 100, Nothing, IntPtr.Zero) thumbNail.Save(strUploadPath & “\thubmnail_” & strFileName)

 Me.imgActual.ImageUrl = “~/images/” & strFileName

Me.imgThumb.ImageUrl = “~/images/” & “thubmnail_” & strFileName

End If

Catch ex As Exception

 End Try

End Sub

Thumbnail image by indiandotnet

 Enjoy programming.

Thanks & Regards

 Rajat Jaiswal


3 thoughts on “Create Thumbnail on the fly by simple step

  1. Hi,

    Very helpful article. I would like to make a suggestion over here. If you can provide any demo link with your articles then it would be more helpful for the needy professionals …. 🙂

  2. Hey

    I have done a great sub to create thubnails and I have yours, there is one issue I cannot get over. It does the resizing well and it reduces the size of the file but not to the point where it should be. Ex: original image of 800/600 with a little over 550kb, reduced to 150/225 (for exam) and the size of it 43kb where it should be no more than 7 or 8…. I need help.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s