Thumbnail of web page RRS feed

  • Question

  • User943411029 posted

    hi friends

    how i can make the thumbnail image of the web pages in the asp.net(vb languages) in web application

    Tuesday, June 24, 2008 7:11 AM

All replies

  • User-976791803 posted
    <script language="VB" runat="server">
      Sub Page_Load(Sender As Object, E As EventArgs)
            Dim originalimg, thumb As System.Drawing.Image
            Dim FileName As String
            Dim inp As New IntPtr()
            Dim width, height As Integer
            Dim rootpath As String
            rootpath = Server.MapPath("/") ' Get Root Application Folder
            FileName = rootpath & Request.QueryString("FileName") ' Root Folder + FileName
                originalimg = originalimg.FromFile(FileName) ' Fetch User Filename
                originalimg = originalimg.FromFile(rootpath & "error.gif") ' Fetch error.gif
            End Try
            ' Get width using QueryString.
            If Request.QueryString("width") = Nothing Then
                width = originalimg.Width  ' Use original Width. 
            ElseIf Request.QueryString("width") = 0 Then  ' Assign default width of 100.
                width = 100
                width = Request.QueryString("width") ' Use User Specified width.
            End If
            ' Get height using QueryString.
            If Request.QueryString("height") = Nothing Then
                height = originalimg.Height ' Use original Height.
            ElseIf Request.QueryString("height") = 0 Then ' Assign default height of 100.
                height = 100
                height = Request.QueryString("height") ' Use User Specified height.
            End If
            thumb = originalimg.GetThumbnailImage(width, height, Nothing, inp)
            ' Sending Response JPEG type to the browser. 
            Response.ContentType = "image/jpeg"
            thumb.Save(Response.OutputStream, Imaging.ImageFormat.Jpeg)
            ' Disposing the objects.
      End Sub



    Where filename should be path relative to the root of the application folder. width & height are optional. If not specified, then the original width and height will be used.

    If width or height are specified as 0, then the default width / height of 100 pixels is used.







    By default the thumbnail image generated is of type JPEG. One can change the Response.Type by changing the following code.

    Response.ContentType = "image/jpeg"
    thumb.Save(Response.OutputStream, Imaging.ImageFormat.Jpeg) 'Change jpeg word 

    with the required supported format(Gif, Png, Bmp etc).

    For details see here http://www.codeproject.com/KB/aspnet/thumbnail_image.aspx 



    <!-- Article Ends --><!-- Main Page Contents End -->
    Tuesday, June 24, 2008 7:23 AM
  • User943411029 posted

    i want thumbnail image of the web page just like the home page of the yahoo.com

    Tuesday, June 24, 2008 7:54 AM
  • User113421904 posted

    Hi gajanan,

    Here is one ASP.NET control for your purpose, see if this helps. 


    Thursday, June 26, 2008 8:22 AM