Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hey

Is it possible to make a screenshot of a window in PHP ?

I've tried this:
PHP
$img = imagegrabscreen();
imagepng($img, 'screenshot.png');

But it creates a black .png file !

This also creates a black screen but the top of the browser is visible !
PHP
$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$browser->Navigate("http://www.libgd.org");

/* Still working? */
while ($browser->Busy) {
    com_message_pump(4000);
}
$im = imagegrabwindow($handle, 0);
$browser->Quit();
imagepng($im, "iesnap.png");
imagedestroy($im);
Posted
Comments
Mohibur Rashid 4-Aug-15 19:08pm    
In short :no
In long: the closest possible can be using javascript. If any browser allow its javascript engine to do so, I will not use that browser and suggest everyone not to use it.

1 solution

PHP is a server-side language, it has no control over the web page once it has been rendered. So, you cannot take a screenshot in PHP. :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900