您好,
我想获取几个页面的屏幕截图并在我的网站上显示。截至目前,我正在使用以下方法:
<?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=\"\">";
?>
但每页有10个或更多图像,此方法需要FOREVER加载它们全部或者它根本不加载它们因为它超时。我想知道一种更有效,更优化,更快捷的方法。
谢谢。
答案 0 :(得分:1)
不确定这是否正是您正在寻找的,但PHP的内置(PHP&gt; = 5.2.2)imagegrabscreen
功能能够返回包含整个屏幕截图的图像资源。但是,根据我的理解(从未使用过它),要求它在Windows系统上运行"allow Apache service to interact with the desktop",这有点挑剔。这些文档页面可能会有所帮助:
imagegrabscreen
Function
imagegrabwindow
Function