How to Generate Thumbnail Image of Webpage in .net C-Sharp ?

This article shows you a solution for generating webpage thumbnail image from URL.

  • Step 1: Download the Websites Screenshot .Net Component.
  • Step 2: Install it on your computer. You will get the WebsitesScreenshot.dll component in the folder.
  • Step 3: Open your visual studio project, add this dll in your project references and try the following sample code.

The following code sample shows how to create thumbnail image of the website page from webpage URL. If you specify the width of the thumbnail, the height will be calculated automatically. It preserves the original aspect ratio. If you specify the height of the thumbnail the width will be calculated automatically.

C# .Net Code.

    
WebsitesScreenshot.WebsitesScreenshot _Obj;
_Obj=new WebsitesScreenshot.WebsitesScreenshot();
WebsitesScreenshot.WebsitesScreenshot.Result _Result;
_Result = _Obj.CaptureWebpage("www.WebsitesScreenshot.com");
if (_Result == WebsitesScreenshot.WebsitesScreenshot.Result.Captured)
{
	_Obj.PreserveAspectRatio = true;
	_Obj.ImageWidth = 100;
	_Obj.SaveImage("c:\\WebsitesScreenshot.jpg");
}
_Obj.Dispose();

VB .Net code.

    
Dim _Obj As New WebsitesScreenshot.WebsitesScreenshot
Dim _Result As WebsitesScreenshot.WebsitesScreenshot.Result
With _Obj
	_Result = .CaptureWebpage("www.WebsitesScreenshot.com")
	If _Result = WebsitesScreenshot.WebsitesScreenshot. _
						Result.Captured Then
		.PreserveAspectRatio = True
		.ImageWidth = 100
		.SaveImage("c:\WebsitesScreenshot.jpg")
	End If
End With
_Obj.Dispose()