I forget where I found this, and I added quite a bit to it. It requires a windows server with IE installed, PHP 5.2.2 or greater with GD and Image Functions. You also have to enable the server* to do this:
PHP Code:
<?php
$nav = isset($_GET['nav'])? $_GET['nav'] : 'http://www.google.com/';
$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$browser->Fullscreen = true;
$browser->Navigate($nav);
$dest = imagecreatetruecolor(144, 107);
/* Still working? */
while ($browser->ReadyState!=4) usleep(10000);
$im = imagegrabwindow($handle, 0);
$browser->Quit();
imagecopyresampled($dest, $im, 0, 0, 0, 0, 144, 107, 1007, 748); // 1007px × 748px
header('Content-type: image/gif');
imagegif($dest);
imagedestroy($im);
imagedestroy($dest);
?>
It outputs the actual image. But you could as easily have it save it to a file.
Problem is that it times out sometimes, in which case you get a blank image (perhaps now solved with new code for /* Still working? */).
Notes: The 1007px x 748px comment is a reminder of the dimensions of my server's virtual screen and appears in the line for which it is a comment. The two values just before that are the size of the thumbnail, they should be proportional to the server's virtual screen size, but otherwise can be dimensions of your choosing. To determine the size of the virtual screen save the $im image to a file and open it in any program that will give you its dimensions.
To write to a file, skip the header and give the filename in the imagegif command, ex:
PHP Code:
imagegif($dest, 'imsnap.gif');
* To enable the server:
services -> [name of the server, like Apache for example] -> LoginTab -> Allow to interact with desktop
You can also edit the registry for this, varies by Windows version.
Bookmarks