By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,022 Members | 856 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,022 IT Pros & Developers. It's quick & easy.

Problem with thumbnail generator

P: 37
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

Expand|Select|Wrap|Line Numbers
  1. function thumb_image($img_file,$url)
  2. {
  3. //** initiate a browser session for screen capture
  4. $browser = new COM("InternetExplorer.Application");
  5. $handle = $browser->HWND;
  6. $browser->Visible = true;
  7. $browser->Fullscreen = true;
  8. $browser->Navigate($url);
  9.  
  10. while ($browser->Busy) {
  11.     com_message_pump(4000);
  12. }
  13. sleep(1);
  14.  
  15. $im = imagegrabscreen(); //** works only with IE, captures the whole screen
  16. $browser->Quit();
  17. imagepng($im, "tmp_".$img_file); //** store workfile
  18.  
  19. $percent = 0.20;   //** factor of thumbnail reduction = 20%
  20. list($width, $height) = getimagesize("tmp_".$img_file);
  21. $new_width = floor($width * $percent);
  22. $new_height = floor($height * $percent);
  23.  
  24. //// Resample
  25. $im2 = imagecreatetruecolor($new_width, $new_height);
  26. imagecopyresampled($im2, $im, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
  27.  
  28. imagepng($im2, $img_file); //** save url image into specified file_name
  29. imagedestroy($im); imagedestroy($im2);
  30. }
  31.  
  32. thumb_image("facebook.png","http://www.google.co.uk"); 
  33. //** call the function
  34. print "<img src=facebook.png>"; echo "<br><br>";       
  35. //** use captured image like any regular picture
Sep 24 '11 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.