takeShot($url); } } private function takeShot($url) { try { $browser = new COM("InternetExplorer.Application"); } catch(Exception $e) { $browser=NULL; } if($browser != NULL) { $handle = $browser->HWND; $browser->Visible = true; $browser->Navigate($url); $browser->Fullscreen = true; $browser->resizable = true; while ($browser->Busy) { com_message_pump(4000); } $im = imagegrabwindow($handle, 0); $height = $browser->Height - 23; $width = $browser->Width - 17; $dest = imagecreatetruecolor($width, $height); imagecopy($dest, $im, 0, 0, 0, 0, $width, $height); $this->image = $dest; $browser->Quit(); return true; } else { return false; } } private function getWidth() { return imagesx($this->image); } private function getHeight() { return imagesy($this->image); } private function resize($width,$height) { $new_image = imagecreatetruecolor($width, $height); imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight()); $this->image = $new_image; } function takeScreenshot($url=NULL) { if($url == NULL) { return false; } return $this->takeShot($url); } function toHeight($height) { $ratio = $height / $this->getHeight(); $width = $this->getWidth() * $ratio; $this->resize($width,$height); } function toWidth($width) { $ratio = $width / $this->getWidth(); $height = $this->getheight() * $ratio; $this->resize($width,$height); } function save($filename=NULL, $imageType="jpeg", $compression=100) { if($filename==NULL || $this->image==NULL) { return false; } $imageType = strtolower($imageType); if($imageType == "jpg" || $imageType =="jpeg" ) { imagejpeg($this->image,$filename,$compression); } elseif($imageType == "gif") { imagegif($this->image,$filename); } elseif($imageType == "png") { imagepng($this->image,$filename); } return true; } } ?>