Log in

View Full Version : script for adding thumbshots to my directory



webiie
09-24-2010, 09:32 AM
Hi Every one

I would like to add thumbshots of websites that are registered on my Directory

creativelads.in

I wish to have a automatic thumbshot creation upon submitting the website by the end user, so as to make the listing more attractive.

My web directory is for web designer ,graphic designer who wish to register and showcase their portfolio

jscheuer1
09-24-2010, 10:03 AM
I forget where I found this, and I added quite a bit to it. It requires a windows server with IE installed, PHP 5.2.2 or greater with GD and Image Functions. You also have to enable the server* to do this:


<?php
$nav = isset($_GET['nav'])? $_GET['nav'] : 'http://www.google.com/';
$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$browser->Fullscreen = true;
$browser->Navigate($nav);
$dest = imagecreatetruecolor(144, 107);

/* Still working? */
while ($browser->ReadyState!=4) usleep(10000);
$im = imagegrabwindow($handle, 0);
$browser->Quit();
imagecopyresampled($dest, $im, 0, 0, 0, 0, 144, 107, 1007, 748); // 1007px × 748px
header('Content-type: image/gif');

imagegif($dest);
imagedestroy($im);
imagedestroy($dest);
?>

It outputs the actual image. But you could as easily have it save it to a file.

Problem is that it times out sometimes, in which case you get a blank image (perhaps now solved with new code for /* Still working? */).

Notes: The 1007px x 748px comment is a reminder of the dimensions of my server's virtual screen and appears in the line for which it is a comment. The two values just before that are the size of the thumbnail, they should be proportional to the server's virtual screen size, but otherwise can be dimensions of your choosing. To determine the size of the virtual screen save the $im image to a file and open it in any program that will give you its dimensions.

To write to a file, skip the header and give the filename in the imagegif command, ex:


imagegif($dest, 'imsnap.gif');


* To enable the server:

services -> [name of the server, like Apache for example] -> LoginTab -> Allow to interact with desktop

You can also edit the registry for this, varies by Windows version.

Michael22
09-24-2010, 11:09 AM
You an also use a Webservice like fadeout.de

More details (in german) at http://fadeout.de/details.php

CU
Michael

webiie
09-24-2010, 02:27 PM
Thanks guys,for the update , i would play around to see, if i can fix it with JOHN's post

jscheuer1
09-24-2010, 03:47 PM
I know it's a lot to take in at once, but I have this working under wamp under windows 7 home. So I know it's possible even without a full blown windows server. So, if you have any questions, let me know.

This also means that if your host isn't setup properly and they are unwilling to allow the changes required, that you can set this up on your local machine and all you would need is communication between it and the live host. If you are not looking for real time results, this could probably even be a cron job on the local machine that takes mail that was sent to it from the live host to get the URL's. In which case you could tell people that it could take up to 12 hours or whatever for the thumbnail to appear. I'm not up on all that communication part, but I'm pretty sure it's possible.