Capture Image Screenshots with PHP

Since PHP 5.2.2 it is now possible to capture a website or any window’s screenshot to an image with PHP as long as it is running on a Window’s machine. Most web-servers are running Linux but this could be useful for a tool on your home Dev server.

Capture Whole Screen

$img = imagegrabscreen();
imagepng($img, 'screenshot.png');

Capture an Application’s Window

$Browser = new COM('InternetExplorer.Application');
$Browserhandle = $Browser->HWND;
$Browser->Visible = true;
$Browser->Fullscreen = true;
$img = imagegrabwindow($Browserhandle, 0);
imagepng($img, 'screenshot.png');
Share this Post:
Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl

Comments are closed.