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

No Responses to “Capture Image Screenshots with PHP”

Leave a Reply:

Name (required):
Mail (will not be published) (required):
Comment (required):
XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>