<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Taking Thumbnails of a Website</title>
	<atom:link href="http://codehill.com/2009/02/taking-thumbnails-of-a-website/feed/" rel="self" type="application/rss+xml" />
	<link>http://codehill.com/2009/02/taking-thumbnails-of-a-website/</link>
	<description>Resources for webmasters and web developers</description>
	<lastBuildDate>Sat, 04 Sep 2010 05:47:30 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>By: Sumit Singh</title>
		<link>http://codehill.com/2009/02/taking-thumbnails-of-a-website/comment-page-1/#comment-2529</link>
		<dc:creator>Sumit Singh</dc:creator>
		<pubDate>Fri, 26 Jun 2009 13:17:39 +0000</pubDate>
		<guid isPermaLink="false">http://codehill.com/?p=505#comment-2529</guid>
		<description>Hi I am facing an issue once publishing the image grabbing functionality on shared hosting I am getting an network related issue.

I talk to service providers also, and they are not able to help me out, can anyone let me know how we can come from the issue.

Please find the URL of my test page.
http://thefogochannel.com/TestHandler.aspx

My sample code is as follows:

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Threading;
using System.Drawing;
using System.Windows.Forms;
using System.Reflection;

public partial class TestHandler : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }

    protected void btnShowThumbnailImage_Click(object sender, EventArgs e)
    {
        string address = &quot;http://&quot; + txtWebsiteAddress.Text;
        int width = Int32.Parse(txtWidth.Text);
        int height = Int32.Parse(txtHeight.Text);
        Bitmap bmp = GetWebSiteThumbnail(address, 800, 600, width, height);
        bmp.Save(Server.MapPath(&quot;~&quot;) + &quot;/images/uploads/thumbnail.bmp&quot;);
        imgWebsiteThumbnailImage.ImageUrl = &quot;~/images/uploads/thumbnail.bmp&quot;;
        imgWebsiteThumbnailImage.Visible = true;
    }

    public static Bitmap GetWebSiteThumbnail(string Url, int BrowserWidth, int BrowserHeight, int ThumbnailWidth, int ThumbnailHeight)
    {
        WebsiteThumbnailImage thumbnailGenerator = new WebsiteThumbnailImage(Url, BrowserWidth, BrowserHeight, ThumbnailWidth, ThumbnailHeight);
        return thumbnailGenerator.GenerateWebSiteThumbnailImage();
    }

    private class WebsiteThumbnailImage
    {
        public WebsiteThumbnailImage(string Url, int BrowserWidth, int BrowserHeight, int ThumbnailWidth, int ThumbnailHeight)
        {
            this.m_Url = Url;
            this.m_BrowserWidth = BrowserWidth;
            this.m_BrowserHeight = BrowserHeight;
            this.m_ThumbnailHeight = ThumbnailHeight;
            this.m_ThumbnailWidth = ThumbnailWidth;
        }

        private string m_Url = null;
        public string Url
        {
            get
            {
                return m_Url;
            }
            set
            {
                m_Url = value;
            }
        }

        private Bitmap m_Bitmap = null;
        public Bitmap ThumbnailImage
        {
            get
            {
                return m_Bitmap;
            }
        }

        private int m_ThumbnailWidth;
        public int ThumbnailWidth
        {
            get
            {
                return m_ThumbnailWidth;
            }
            set
            {
                m_ThumbnailWidth = value;
            }
        }

        private int m_ThumbnailHeight;
        public int ThumbnailHeight
        {
            get
            {
                return m_ThumbnailHeight;
            }
            set
            {
                m_ThumbnailHeight = value;
            }
        }

        private int m_BrowserWidth;
        public int BrowserWidth
        {
            get
            {
                return m_BrowserWidth;
            }
            set
            {
                m_BrowserWidth = value;
            }
        }

        private int m_BrowserHeight;
        public int BrowserHeight
        {
            get
            {
                return m_BrowserHeight;
            }
            set
            {
                m_BrowserHeight = value;
            }
        }

        public Bitmap GenerateWebSiteThumbnailImage()
        {
            Thread m_thread = new Thread(new ThreadStart(_GenerateWebSiteThumbnailImage));
            m_thread.SetApartmentState(ApartmentState.STA);
            m_thread.Start();
            m_thread.Join();
            return m_Bitmap;
        }

        private void _GenerateWebSiteThumbnailImage()
        {
            WebBrowser m_WebBrowser = new WebBrowser();
            m_WebBrowser.ScrollBarsEnabled = false;
            m_WebBrowser.Navigate(m_Url);
            m_WebBrowser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(WebBrowser_DocumentCompleted);
            while (m_WebBrowser.ReadyState != WebBrowserReadyState.Complete)
                System.Windows.Forms.Application.DoEvents();
            m_WebBrowser.Dispose();
        }

        private void WebBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            WebBrowser m_WebBrowser = (WebBrowser)sender;
            m_WebBrowser.ClientSize = new Size(this.m_BrowserWidth, this.m_BrowserHeight);
            m_WebBrowser.ScrollBarsEnabled = false;
            m_Bitmap = new Bitmap(m_WebBrowser.Bounds.Width, m_WebBrowser.Bounds.Height);
            m_WebBrowser.BringToFront();
            m_WebBrowser.DrawToBitmap(m_Bitmap, m_WebBrowser.Bounds);
            m_Bitmap = (Bitmap)m_Bitmap.GetThumbnailImage(m_ThumbnailWidth, m_ThumbnailHeight, null, IntPtr.Zero);
        }
    }
}</description>
		<content:encoded><![CDATA[<p>Hi I am facing an issue once publishing the image grabbing functionality on shared hosting I am getting an network related issue.</p>
<p>I talk to service providers also, and they are not able to help me out, can anyone let me know how we can come from the issue.</p>
<p>Please find the URL of my test page.<br />
<a href="http://thefogochannel.com/TestHandler.aspx" rel="nofollow">http://thefogochannel.com/TestHandler.aspx</a></p>
<p>My sample code is as follows:</p>
<p>using System;<br />
using System.Collections.Generic;<br />
using System.Web;<br />
using System.Web.UI;<br />
using System.Web.UI.WebControls;<br />
using System.IO;<br />
using System.Threading;<br />
using System.Drawing;<br />
using System.Windows.Forms;<br />
using System.Reflection;</p>
<p>public partial class TestHandler : System.Web.UI.Page<br />
{<br />
    protected void Page_Load(object sender, EventArgs e)<br />
    {</p>
<p>    }</p>
<p>    protected void btnShowThumbnailImage_Click(object sender, EventArgs e)<br />
    {<br />
        string address = &#8220;http://&#8221; + txtWebsiteAddress.Text;<br />
        int width = Int32.Parse(txtWidth.Text);<br />
        int height = Int32.Parse(txtHeight.Text);<br />
        Bitmap bmp = GetWebSiteThumbnail(address, 800, 600, width, height);<br />
        bmp.Save(Server.MapPath(&#8220;~&#8221;) + &#8220;/images/uploads/thumbnail.bmp&#8221;);<br />
        imgWebsiteThumbnailImage.ImageUrl = &#8220;~/images/uploads/thumbnail.bmp&#8221;;<br />
        imgWebsiteThumbnailImage.Visible = true;<br />
    }</p>
<p>    public static Bitmap GetWebSiteThumbnail(string Url, int BrowserWidth, int BrowserHeight, int ThumbnailWidth, int ThumbnailHeight)<br />
    {<br />
        WebsiteThumbnailImage thumbnailGenerator = new WebsiteThumbnailImage(Url, BrowserWidth, BrowserHeight, ThumbnailWidth, ThumbnailHeight);<br />
        return thumbnailGenerator.GenerateWebSiteThumbnailImage();<br />
    }</p>
<p>    private class WebsiteThumbnailImage<br />
    {<br />
        public WebsiteThumbnailImage(string Url, int BrowserWidth, int BrowserHeight, int ThumbnailWidth, int ThumbnailHeight)<br />
        {<br />
            this.m_Url = Url;<br />
            this.m_BrowserWidth = BrowserWidth;<br />
            this.m_BrowserHeight = BrowserHeight;<br />
            this.m_ThumbnailHeight = ThumbnailHeight;<br />
            this.m_ThumbnailWidth = ThumbnailWidth;<br />
        }</p>
<p>        private string m_Url = null;<br />
        public string Url<br />
        {<br />
            get<br />
            {<br />
                return m_Url;<br />
            }<br />
            set<br />
            {<br />
                m_Url = value;<br />
            }<br />
        }</p>
<p>        private Bitmap m_Bitmap = null;<br />
        public Bitmap ThumbnailImage<br />
        {<br />
            get<br />
            {<br />
                return m_Bitmap;<br />
            }<br />
        }</p>
<p>        private int m_ThumbnailWidth;<br />
        public int ThumbnailWidth<br />
        {<br />
            get<br />
            {<br />
                return m_ThumbnailWidth;<br />
            }<br />
            set<br />
            {<br />
                m_ThumbnailWidth = value;<br />
            }<br />
        }</p>
<p>        private int m_ThumbnailHeight;<br />
        public int ThumbnailHeight<br />
        {<br />
            get<br />
            {<br />
                return m_ThumbnailHeight;<br />
            }<br />
            set<br />
            {<br />
                m_ThumbnailHeight = value;<br />
            }<br />
        }</p>
<p>        private int m_BrowserWidth;<br />
        public int BrowserWidth<br />
        {<br />
            get<br />
            {<br />
                return m_BrowserWidth;<br />
            }<br />
            set<br />
            {<br />
                m_BrowserWidth = value;<br />
            }<br />
        }</p>
<p>        private int m_BrowserHeight;<br />
        public int BrowserHeight<br />
        {<br />
            get<br />
            {<br />
                return m_BrowserHeight;<br />
            }<br />
            set<br />
            {<br />
                m_BrowserHeight = value;<br />
            }<br />
        }</p>
<p>        public Bitmap GenerateWebSiteThumbnailImage()<br />
        {<br />
            Thread m_thread = new Thread(new ThreadStart(_GenerateWebSiteThumbnailImage));<br />
            m_thread.SetApartmentState(ApartmentState.STA);<br />
            m_thread.Start();<br />
            m_thread.Join();<br />
            return m_Bitmap;<br />
        }</p>
<p>        private void _GenerateWebSiteThumbnailImage()<br />
        {<br />
            WebBrowser m_WebBrowser = new WebBrowser();<br />
            m_WebBrowser.ScrollBarsEnabled = false;<br />
            m_WebBrowser.Navigate(m_Url);<br />
            m_WebBrowser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(WebBrowser_DocumentCompleted);<br />
            while (m_WebBrowser.ReadyState != WebBrowserReadyState.Complete)<br />
                System.Windows.Forms.Application.DoEvents();<br />
            m_WebBrowser.Dispose();<br />
        }</p>
<p>        private void WebBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)<br />
        {<br />
            WebBrowser m_WebBrowser = (WebBrowser)sender;<br />
            m_WebBrowser.ClientSize = new Size(this.m_BrowserWidth, this.m_BrowserHeight);<br />
            m_WebBrowser.ScrollBarsEnabled = false;<br />
            m_Bitmap = new Bitmap(m_WebBrowser.Bounds.Width, m_WebBrowser.Bounds.Height);<br />
            m_WebBrowser.BringToFront();<br />
            m_WebBrowser.DrawToBitmap(m_Bitmap, m_WebBrowser.Bounds);<br />
            m_Bitmap = (Bitmap)m_Bitmap.GetThumbnailImage(m_ThumbnailWidth, m_ThumbnailHeight, null, IntPtr.Zero);<br />
        }<br />
    }<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DotNetShoutout</title>
		<link>http://codehill.com/2009/02/taking-thumbnails-of-a-website/comment-page-1/#comment-2212</link>
		<dc:creator>DotNetShoutout</dc:creator>
		<pubDate>Tue, 09 Jun 2009 11:08:47 +0000</pubDate>
		<guid isPermaLink="false">http://codehill.com/?p=505#comment-2212</guid>
		<description>&lt;strong&gt;Taking Thumbnails of a Website &#124; CodeHill...&lt;/strong&gt;

Thank you for submitting this cool story - Trackback from DotNetShoutout...</description>
		<content:encoded><![CDATA[<p><strong>Taking Thumbnails of a Website | CodeHill&#8230;</strong></p>
<p>Thank you for submitting this cool story &#8211; Trackback from DotNetShoutout&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Amgad Suliman</title>
		<link>http://codehill.com/2009/02/taking-thumbnails-of-a-website/comment-page-1/#comment-2157</link>
		<dc:creator>Amgad Suliman</dc:creator>
		<pubDate>Tue, 02 Jun 2009 19:41:17 +0000</pubDate>
		<guid isPermaLink="false">http://codehill.com/?p=505#comment-2157</guid>
		<description>Thank you Matthew for the comment. Could you please download the source code of SiteCapture, an small app I developed based on the code in this post, maybe it does what you are looking for. The link is at the top of the page.</description>
		<content:encoded><![CDATA[<p>Thank you Matthew for the comment. Could you please download the source code of SiteCapture, an small app I developed based on the code in this post, maybe it does what you are looking for. The link is at the top of the page.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matthew M.</title>
		<link>http://codehill.com/2009/02/taking-thumbnails-of-a-website/comment-page-1/#comment-2154</link>
		<dc:creator>Matthew M.</dc:creator>
		<pubDate>Tue, 02 Jun 2009 19:00:49 +0000</pubDate>
		<guid isPermaLink="false">http://codehill.com/?p=505#comment-2154</guid>
		<description>Unfortunately, there&#039;s one small problem with this.  Don&#039;t use Google as your demonstration project.. use Digg, or Slashdot.  What you&#039;ll notice.. is the cropping!  The method that you&#039;re using will only grab 800x600, not 800x4000.

Personally, I think that&#039;s a bit annoying.. but you&#039;re definitely spot on for what you need to do, to do what you&#039;re doing.  There isn&#039;t a better solution that I&#039;ve found yet for grabbing an entire thumbnail of a webpage.

It would be nice if we could do this without relying on the WebBrowser control as well.  I looked once at WebKit.. there was a .NET port, but it wasn&#039;t finished/working, etc.

- Matthew</description>
		<content:encoded><![CDATA[<p>Unfortunately, there&#8217;s one small problem with this.  Don&#8217;t use Google as your demonstration project.. use Digg, or Slashdot.  What you&#8217;ll notice.. is the cropping!  The method that you&#8217;re using will only grab 800&#215;600, not 800&#215;4000.</p>
<p>Personally, I think that&#8217;s a bit annoying.. but you&#8217;re definitely spot on for what you need to do, to do what you&#8217;re doing.  There isn&#8217;t a better solution that I&#8217;ve found yet for grabbing an entire thumbnail of a webpage.</p>
<p>It would be nice if we could do this without relying on the WebBrowser control as well.  I looked once at WebKit.. there was a .NET port, but it wasn&#8217;t finished/working, etc.</p>
<p>- Matthew</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Amgad Suliman</title>
		<link>http://codehill.com/2009/02/taking-thumbnails-of-a-website/comment-page-1/#comment-186</link>
		<dc:creator>Amgad Suliman</dc:creator>
		<pubDate>Mon, 16 Mar 2009 04:28:07 +0000</pubDate>
		<guid isPermaLink="false">http://codehill.com/?p=505#comment-186</guid>
		<description>Thank you blogville, appreciate it :)</description>
		<content:encoded><![CDATA[<p>Thank you blogville, appreciate it <img src='http://codehill.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: CodeHill &#187; An Open Source Website Screen Capture Program</title>
		<link>http://codehill.com/2009/02/taking-thumbnails-of-a-website/comment-page-1/#comment-175</link>
		<dc:creator>CodeHill &#187; An Open Source Website Screen Capture Program</dc:creator>
		<pubDate>Sat, 14 Mar 2009 16:02:56 +0000</pubDate>
		<guid isPermaLink="false">http://codehill.com/?p=505#comment-175</guid>
		<description>[...] few weeks ago I posted Taking Thumbnails of a Website, that shows how to take a screen shot of a website using the Web Browser control. I used the code [...]</description>
		<content:encoded><![CDATA[<p>[...] few weeks ago I posted Taking Thumbnails of a Website, that shows how to take a screen shot of a website using the Web Browser control. I used the code [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: blogville</title>
		<link>http://codehill.com/2009/02/taking-thumbnails-of-a-website/comment-page-1/#comment-171</link>
		<dc:creator>blogville</dc:creator>
		<pubDate>Fri, 13 Mar 2009 20:58:46 +0000</pubDate>
		<guid isPermaLink="false">http://codehill.com/?p=505#comment-171</guid>
		<description>Interesting code. Nice work. Could use something like that! :)</description>
		<content:encoded><![CDATA[<p>Interesting code. Nice work. Could use something like that! <img src='http://codehill.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>
