发表时间:2014-09-05来源:网络
PHP使用GD库实现截屏
PHP5.2.2以上版本的GD库实现了两个截屏函数 imagegrabscreen 和 imagegrabwindow
分别用于截取整个屏幕和截取某个窗口(同ALT+PrintScreen)的屏幕。
1. 截取整个屏幕 Screenshot
<?php
$im = imagegrabscreen () ;
imagepng ( $im , " myscreenshot.png " ) ;
?>
2. 截取一个窗口 Capture a window (IE for example)
<?php
$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!
<?php
$browser = new COM ( " InternetExplorer.Application " ) ;
$handle = $browser -> HWND ;
$browser -> Visible = true ;
$browser -> Navigate ( " http://www.21andy.com/blog/ " ) ;
/* 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
<?php
$browser = new COM ( " InternetExplorer.Application " ) ;
$handle = $browser -> HWND ;
$browser -> Visible = true ;
$browser -> FullScreen = true ;
$browser -> Navigate ( " http://www.21andy.com/blog/ " ) ;
/* 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 " ) ;
?>
I use Internet Example Explorer as example, if you like to play more with IE and com, check out the IBrowser2 documentation at MSDN. It should work with any kind of window as long as you give the correct handle (usually $obj->HWND).
* php_gd2.dll for 5.2.x thread safe build
* php gd image documentation
* IE manual (useful to tweak it from com_dotnet
在测试过程中我并没有出现手册中说的那种效果,而是一张纯黑的图片,这是为什么呢?
可能有两种情况,第一种情况就是这个COM组件只适用于WINDOWS服务器,因为他没有IE浏览器;第二种情况就是没有打开允许服务与桌面交互!其中第二种情况最为常见(默认是关闭的),打开的方法:点击计算机(我的电脑) -> 右键 -> 管理 -> 服务和应用程序 -> 服务 -> Apache -> 右键 -> 属性 -> 登录 -> 选中允许服务与桌面交互。
如果是第二种情况的话,我安装的是apache集成包,这样的话就找不到apache的服务在哪里,所以第二种方法的设置我没有成功,如有成功者,希望指点一下。
摘自 张大鹏
下一篇:php正则取得页面所有的图片地址
CI框架连接数据库配置操作以及多数据库操作
asp 简单读取数据表并列出来 ASP如何快速从数据库读取大量数据
C语言关键字及其解释介绍 C语言32个关键字详解
C语言中sizeof是什么意思 c语言里sizeof怎样用法详解
PHP中的魔术方法 :__construct, __destruct , __call, __callStatic,__get, __set, __isset, __unset , __sleep,
PHP中的(++i)前缀自增 和 (i++)后缀自增
将视频设置为Android手机开机动画的教程
最简单的asp登陆界面代码 asp登陆界面源代码详细介绍
常用dos命令及语法
PHP中include和require区别之我见
2014-09-05
2022-03-20
2022-03-21
2022-03-24
2014-09-05
2014-09-05
2015-07-05
2014-09-05
2022-03-21
2014-09-05