Zentara,

----- Original Message ----- From: "zentara" <[EMAIL PROTECTED]>
To: <beginners@perl.org>
Sent: Friday, July 21, 2006 11:16 AM
Subject: Re: Create Snapshot of website


On Thu, 20 Jul 2006 19:35:21 -0500, [EMAIL PROTECTED] ("Mike
Blezien") wrote:

I been trying to research the feasibility of using Perl and/or special module(s) that can capture a website page and create a "snapshot" of the website page, or
like a thumbnail image. I've seen this done, but not sure if it can be done
using Perl or Perl modules.

if anyone on the list may have done this or have some information I could
review, it be much appreciated.

Yeah, I just took a quick look at it, and it is feasible, but there are
some problems to overcome. First, this method only works on linux.
There are variations in the remote command syntax to load pages in
diffferent browsers, etc, etc.

Anyways, the ImageMagick "import" method, will allow you to snap the
screenshot of a specific X window id.

So say for instance, you use xwininfo and determine that mozilla has
id 0x00002a, now you can use that in your perl script to snap the
screenshot.

Another problem, is that the perl script must be running on the same
virtual desktop as the browser, or it will complain it can't find it. So
you must move your script to the right virtual desktop, minimize it ( so
it dosn't obscure the mozilla shot, then do the import.
You can use the X11::WMCtrl module to handle this part.

For the browsing, you can just issue remote browsing commands to
mozilla(browser) and wait a few minutes to be sure it's loaded.

Then do the import. In the example below, I used backticks, but the
ImageMagick module can use it's own import to do this....I have not
figured out that syntax yet.

So here is a simple proof of concept, assuming you are running on linux.
A simple example , assuming the browser is X id 0x00002a ( from
xwininfo).

#!/usr/bin/perl
use warnings;
use strict;
use Image::Magick;

my $blob = `import -window 0xa00022  jpg:`;  #the browser
#my $blob = `import -`;  #postscript produced
#print "$blob\n";
# now $blob is in memory and you can do what you
# want with it.

my $output = Image::Magick->new(magick=>'jpg');
$output->BlobToImage( $blob );
$output->Resize(geometry=>'160x120');
$output->Write( $0.'.jpg');

exit;
# png works too
__END__

I'm wondering if the [Win32::CaptureIE] >> http://search.cpan.org/~psme/Win32-CaptureIE-1.30/CaptureIE.pm

module may do the trick for what we need. Have you or anyone else used this module with success ?

Mickalo

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to