I am trying to run a script that generates thumbnail images of websites.
When I run the script I get the following error message.
Fatal error: Class 'COM' not found in /home/online/public/tutor/thumb.php on line 9
If I run the script locally I do not get the error,
however what I do see is a thumbnail image with a black background.
This is the script
When I run the script I get the following error message.
Fatal error: Class 'COM' not found in /home/online/public/tutor/thumb.php on line 9
If I run the script locally I do not get the error,
however what I do see is a thumbnail image with a black background.
This is the script
Code:
function thumb_image($img_file,$url)
{
//** initiate a browser session for screen capture
$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$browser->Fullscreen = true;
$browser->Navigate($url);
while ($browser->Busy) {
com_message_pump(4000);
}
sleep(1);
$im = imagegrabscreen(); //** works only with IE, captures the whole screen
$browser->Quit();
imagepng($im, "tmp_".$img_file); //** store workfile
$percent = 0.20; //** factor of thumbnail reduction = 20%
list($width, $height) = getimagesize("tmp_".$img_file);
$new_width = floor($width * $percent);
$new_height = floor($height * $percent);
//// Resample
$im2 = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($im2, $im, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
imagepng($im2, $img_file); //** save url image into specified file_name
imagedestroy($im); imagedestroy($im2);
}
thumb_image("facebook.png","http://www.google.co.uk");
//** call the function
print "<img src=facebook.png>"; echo "<br><br>";
//** use captured image like any regular picture