How can I create a screenshot of a website using PHP and the GD library.
How can I take a screenshot of a website with PHP and GD?
Open challenge? This isn't a code-writing site. –
Salaried
You can use thumbshots.org –
Displume
While you might be able to do something with imagegrabscreen
or imagegrabwindow
you'd only be able to use it on a Windows box, and even then it would be tricky.
You'd have to open a browser window to the specified url (you could do that with exec
) and grab a screenshot using the aforementioned methods.
Here's an example from the manual entry for imagegrabwindow
:
<?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);
?>
Hi Ross, the code above gives following error/Warning PHP Warning: Module 'gd' already loaded in Unknown on line 0 PHP Fatal error: Uncaught exception 'com_exception' with message 'Failed to create COM object `InternetExplorer.Application': Access is denied. ' –
Cryology
I'm having trouble even getting imagegrabscreen to work. As I said, I only copied that code from the manual. All I can suggest is that you follow the note on php.net/imagegrabscreen (assuming you're using Apache). –
Salaried
(Note that on Vista enabling Apache desktop support, restarting the service and the server still does not work) –
Salaried
Website is rendered on client side, while PHP and GD are server side. You may also check this website out. Hope it helps.
Thanks for the link, it works, expect that HTML5/canvas is not implemented. This solution works better. –
Dap
© 2022 - 2024 — McMap. All rights reserved.