PHP实现网页截图功能
所属分类:PHP工具与代码
  转载自http://hi.baidu.com/fising/blog/item/2526b58f27268fe6f11f3617

注意:运行环境需要:PHP 5.2.2 + GD2

[code]<?php
$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$browser->Fullscreen = true;
$browser->Navigate("http://www.11jn.com");
/* Still working? */
while ($browser->Busy) {
com_message_pump(4000);
}

$im = imagegrabwindow($handle, 0);
$browser->Quit();
//imagejpeg($im, "tmp.jpg");
//$old_img=imagecreatefromjpeg("tmp.jpg");
$new_img = imagecreatetruecolor(200,150);
imagecopyresampled($new_img,$im,0,0,0,0,200,150,1024,768);
imagejpeg($new_img , 'image/'.time().'.jpg',100);
imagedestroy($new_img);?>[/code]