Reputation: 3093
Hi,
I want to get the screenshot of several pages and display them on my website. As of now, I am using the method below:
<?php
$site = $screenurl;
$image = file_get_contents("https://www.googleapis.com/pagespeedonline/v1/runPagespeed?url=$site&screenshot=true");
$image = json_decode($image, true);
$image = $image['screenshot']['data'];
$image = str_replace(array('_','-'),array('/','+'),$image);
echo "<img src=\"data:image/jpeg;base64,".$image."\" alt=\"\">";
?>
but with 10 or more images per page, this method takes FOREVER to load them all or it wont even load them at all because it times out. I would like to know a more effective, optimized and faster way to do this.
Thank you.
Upvotes: 0
Views: 400
Reputation: 1716
Not sure if this is exactly what you're looking for, but PHP's built-in (PHP >= 5.2.2) imagegrabscreen
function is capable of returning an image resource containing a screenshot of the whole screen. It is sort of picky, though, from what I understand (never used it myself), requiring it to be run on a Windows system and "allow Apache service to interact with the desktop". These documentation pages could be helpful:
imagegrabscreen
Function
imagegrabwindow
Function
Upvotes: 1