Jump to content
EduGeek EdSec 2026 is Go! 27th Oct in Derby! Join us for a day of EdTech security focused talks, networking, and an evening social ×

Creating a graphical Thumbnail of a website by passing a URL


Recommended Posts

Posted

Hello All,

 

I'm currently working on a web based project and I need to be able to create website page thumbnails on the fly using code. Does anyone know of any FREE example code on the web to be able to do this? I would prefer to be able to do this in CGI, Java, PHP, C/C++ on Linux.

 

Can anyone provide any pointers?

 

TIA! :)

Posted

thumbnails of images? Here's a function using PHP and GD.

 

function image_thumbnail($filename) {
/* This function will take an existing image on the server and render a thumbnail
    image for the website to keep its layout. */
       
// Set a maximum height and width
$width = 200;
$height = 200;

// Get new dimensions
list($width_orig, $height_orig) = getimagesize($filename);

if ($width && ($width_orig < $height_orig)) {
  $width = ($height / $height_orig) * $width_orig;
} else {
  $height = ($width / $width_orig) * $height_orig;
}

// Resample
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);

// Output
imagejpeg($image_p, '', 100);
}

Posted
Cheers for that Geoff, but what i'm actually after is a snippet of code that will output a small image of a whole HTML website when you pass it a website url. For example if I pass in http://www.yahoo.co.uk into it I end up with a small image of the yahoo website at that moment in time. I've seen bodged way to do this by running mozilla and using kill processes to take off the nav bars and use an app to snapshot that screen but this takes extra cpu/memory overhead as is a bit clunky.
Posted

Thanks a lot Geoff!

 

I believe this khtml2png will be most useful to me!

 

Also, having said that I've just come across a free HTML viewer in Java source, so if khtml2png doesnt do the trick i'm sure I could modify the HTML viewer to render the output as a graphic file.

 

I will give them a try and let you know how I get on.

 

Many Thanks!

 

:)

Posted
Not sure if this helps but opera on the mac does that when you use tabbed browsing :) Prolly does it on the windows version and other versions too :)

 

Don't really think that counts... ;)

 

I'm currently working on a web based project and I need to be able to create website page thumbnails on the fly using code.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...