PHP imagegrabscreen和imagegrabwindow(截取网站缩略图)的实例代码_php实例

WBOY
Release: 2016-05-17 08:53:24
Original
1046 people have browsed it
1. 截取整个屏幕 Screenshot
复制代码代码如下:

$im = imagegrabscreen();
imagepng($im, “myscreenshot.png”);
?>

2. 截取一个窗口 Capture a window (IE for example)
复制代码代码如下:

$browser = new COM(“InternetExplorer.Application”);
$handle = $browser->HWND;
$browser->Visible = true;
$im = imagegrabwindow($handle);
$browser->Quit();
imagepng($im, “iesnap.png”);
$im = imagegrabscreen();
?>

3. 截取IE内容 Capture a window(IE for example) but with its content!
复制代码代码如下:

$browser = new COM(“InternetExplorer.Application”);
$handle = $browser->HWND;
$browser->Visible = true;
$browser->Navigate(“http://www.jb51.net”);

/* Still working? */
while ($browser->Busy) {
com_message_pump(4000);
}
$im = imagegrabwindow($handle, 0);
$browser->Quit();
imagepng($im, “iesnap.png”);
?>

4. 截取IE的全屏模式IE in fullscreen mode
复制代码代码如下:

$browser = new COM(“InternetExplorer.Application”);
$handle = $browser->HWND;

$browser->Visible = true;
$browser->FullScreen = true;
$browser->Navigate(“http://www.jb51.net”);

/* Is it completely loaded? (be aware of frames!)*/
while ($browser->Busy) {
com_message_pump(4000);
}
$im = imagegrabwindow($handle, 0);
$browser->Quit();
imagepng($im, “iesnap.png”);
?>

上面就是说如何使用PHP COM调用IE窗口打开网页进行截屏,但很多朋友得到的结果只是一张纯黑的图片,这是为什么呢?
可能有两种情况,第一种情况就是这个COM组件只适用于WINDOWS服务器,其它系统的服务器是不支持的,因为他没有IE浏览器,第二种情况就是没有打开允许服务与桌面交互!其中第二种情况最为常见,打开的方法就是点击计算机(我的电脑) -> 右键 -> 管理 -> 服务和应用程序 -> 服务 -> Apache(我自己使用apache服务器) -> 右键 -> 属性 -> 登录 -> 登录身份下面既是!
Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!