<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/stylesheets/rss.css" type="text/css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Dev411 Blog: Automated web screen shots with Perl</title>
    <link>http://www.dev411.com/blog/2006/07/21/automated-web-screen-shots-with-perl</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>John Wang on Technology</description>
    <item>
      <title>Automated web screen shots with Perl</title>
      <description>&lt;p&gt;I've been looking for a program that will take full screen shots of web pages even when the web page is larger than the window size on my physical screen, requiring scrolling. This morning I found such a program in Petr &#352;mejkal's &lt;a href="http://search.cpan.org/~psme/Win32-CaptureIE-1.30/CaptureIE.pm" class="fix"&gt;Win32::CaptureIE&lt;/a&gt; when it was mentioned by Displeaser on &lt;a href="http://forums.devshed.com"&gt;DevShed Forums&lt;/a&gt; in the "&lt;a href="http://forums.devshed.com/perl-programming-6/screenshot-of-webpage-370275.html"&gt;Screenshot of webpage&lt;/a&gt;" thread. It uses ImageMagick for image manipulation.&lt;/p&gt;

&lt;p&gt;From reading the &lt;span class="fix"&gt;Win32::CaptureIE&lt;/span&gt; POD, the CapturePage function does exactly what I want:&lt;/p&gt;

&lt;div class="quote_simple"&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;CapturePage ( )&lt;/strong&gt; Captures whole page currently loaded in the Internet Explorer window. Only the page content will be captured - no window, no scrollbars. If the page is smaller than the window only the occupied part of the window will be captured. If the page is longer (scrollbars are active) the function will capture the whole page step by step by scrolling the window content (in all directions) and will return a complete image of the page.&lt;/em&gt;&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;After installing ImageMagick, &lt;span class="fix"&gt;Image::Magick&lt;/span&gt; and &lt;span class="fix"&gt;Win32::CaptureIE&lt;/span&gt; on my Windows / ActiveState Perl system, I generated &lt;a href="/images/articles/200607/dev411blog_win32captureie.png"&gt;this screen shot&lt;/a&gt; with the following short program using no additional processing:&lt;/p&gt;

&lt;pre&gt;#!perl
use strict; use warnings;
use Win32::CaptureIE;

StartIE( width =&gt; 900 );
Navigate( 'http://www.dev411.com/blog/' );

my $img = CapturePage();
$img-&gt;Write( 'capture.png' );
QuitIE;&lt;/pre&gt;

&lt;p&gt;Perl and CPAN continue to amaze me with their treasure trove of functionality. Are there  similar tools for using Firefox, Linux, other image libraries or languages?&lt;/p&gt;

&lt;div class="update"&gt;&lt;p&gt;&lt;b&gt;UPDATE:&lt;/b&gt; ishnid has found two programs with CLIs (posted to the same thread):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://khtml2png.sourceforge.net/"&gt;khtml2png&lt;/a&gt; on SourceForge. This is a command-line program that looks like it can be run without a browser. It uses &lt;span class="fix"&gt;libkhtml&lt;/span&gt; (used by Konqueror) and ImageMagick's &lt;span class="fix"&gt;convertn&lt;/span&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://pearlcrescent.com/products/pagesaver/"&gt;Pearl Crescent Page Saver&lt;/a&gt;, a commercial app but available in a free version. This is a Firefox extension and requires the browser.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;b&gt;UPDATE 2:&lt;/b&gt;: I recently tried Win32::CaptureIE with ImageMagick 6.3.0 and it doesn't work. Apparently there used to be a link to "PerlMagick" in older versions of ImageMagick that may not exist anymore. Unfortunately Win32::CaptureIE relies on PerlMagick.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;UPDATE 3:&lt;/b&gt;: I just tried the free version of Pearl Crescent with Firefox 1.5.0.7 which it says it should support but I get a "Download error" with pageserverbasic-1.3.xpi.&lt;/p&gt;

&lt;/div&gt;</description>
      <pubDate>Fri, 21 Jul 2006 10:02:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:829678746bcf7e466ae1a607174ea863</guid>
      <author>John Wang</author>
      <link>http://www.dev411.com/blog/2006/07/21/automated-web-screen-shots-with-perl</link>
      <category>imagemagick</category>
      <category>ie</category>
      <category>perl</category>
    </item>
    <item>
      <title>"Automated web screen shots with Perl" by Demoric</title>
      <description>&lt;p&gt;Version 1.4 of Pearl Crescent has been released and works well with firefox 2.0.0.2&lt;/p&gt;</description>
      <pubDate>Sun, 11 Mar 2007 15:49:28 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:77468023-6606-4bd2-886b-1536b10b65ea</guid>
      <link>http://www.dev411.com/blog/2006/07/21/automated-web-screen-shots-with-perl#comment-165</link>
    </item>
    <item>
      <title>"Automated web screen shots with Perl" by John Wang</title>
      <description>&lt;p&gt;Great idea. I&amp;#8217;d be excited about a solution that could run without a windowing system as well. Definately something to keep an eye out for.&lt;/p&gt;</description>
      <pubDate>Fri, 21 Jul 2006 15:44:37 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:</guid>
      <link>http://www.dev411.com/blog/2006/07/21/automated-web-screen-shots-with-perl#comment-46</link>
    </item>
    <item>
      <title>"Automated web screen shots with Perl" by Chisel Wright</title>
      <description>&lt;p&gt;I&amp;#8217;ve looked around for this before without much success.&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;m amazed that someone hasn&amp;#8217;t found a way to hook into the Gecko engine, and instead of rendering to Browser, rendered to a PNG/JPG file.&lt;/p&gt;


	&lt;p&gt;I wouldn&amp;#8217;t know where to start looking, but it seems that all the hard-work has been dome already, and some clever b**tard just needs to redirect the output.&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;m not keen on solutions that require you to be running in/under X/Windows to render the page.&lt;/p&gt;


	&lt;p&gt;One day &amp;#8230;&lt;/p&gt;</description>
      <pubDate>Fri, 21 Jul 2006 14:02:53 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:</guid>
      <link>http://www.dev411.com/blog/2006/07/21/automated-web-screen-shots-with-perl#comment-45</link>
    </item>
  </channel>
</rss>
