perkiset

There was a post over at Syndk8 about someone needing to get a screen shot of a website via

PHP

 . I was trying to do this quite a while ago for one of my more ... erm ... advanced cloaking projects Applause but the need dissipated. But based on the post, I decided to go see if anyone had made any more progress along those lines. When I had last checked, the best way was with a for pay ($$$$$) app that would do it for you... of course that just pissed me off  Applause

So here is an abbreviation of an interesting site that I found. The entire post can be found here:
http://blog.thepimp

.net

 /index.

php

 /post/2007/04/17/Screen-capture-with-

PHP

 -and-GD

quote

To get a snapshot of a HTML page, a window or a complete screen was always something tricky to do in

PHP

 .

That's why I finally sit down and implemented imagegrabscreen and imagegrabwindow . They capture respectively the whole screen or a window (using its handle).

Thanks to Edin Kadribašić, you can fetch a 5.2.x (Threadsage build only) DLL <a href="http://blog.thepimp

.net

 /misc/gd/

php

 _gd2-5.2-TS.zip">here</a>, simply replace the

php

 _gd2.dll by this one (it is what will be in 5.2.2).

<>[Perk notes: This does not instruct the browser where to go, only to grab the rendered HTML found in the current IE window...]

Capture a window (IE for example) with its content

<?

php

 
$browser = new COM("Inte

rnet

 Explorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$browser->Navigate("http://blog.thepimp

.net

 ");

/* Still working? */
while ($browser->Busy) {
    com_message_pump(4000);
}
$im = imagegrabwindow($handle, 0);
$browser->Quit();
imagepng($im, "iesnap.png");
?>


IE in fullscreen mode

<?

php

 
$browser = new COM("Inte

rnet

 Explorer.Application");
$handle = $browser->HWND;

$browser->Visible = true;
$browser->FullScreen = true;
$browser->Navigate("http://blog.thepimp

.net

 ");

/* Is it completely loaded? (be aware of frames!)*/
while ($browser->Busy) {
    com_message_pump(4000);
}
$im = imagegrabwindow($handle, 0);
$browser->Quit();
imagepng($im, "iesnap.png");
?>



vsloathe

Don't quote me, but I'm pretty sure you can do it straight away with imagick out of the box (so to speak, no box since it's FOSS Applause )


Perkiset's Place Home   Politics @ Perkiset's