NetDiag Posted November 8, 2006 Posted November 8, 2006 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!
Geoff Posted November 8, 2006 Posted November 8, 2006 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); }
NetDiag Posted November 8, 2006 Author Posted November 8, 2006 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.
Geoff Posted November 8, 2006 Posted November 8, 2006 Yes, that's all I can find too. html2jpeg: http://marginalhacks.com/Hacks/html2jpg/
NetDiag Posted November 8, 2006 Author Posted November 8, 2006 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!
webman Posted November 8, 2006 Posted November 8, 2006 What about this or this? They're more services than code though.
mac_shinobi Posted November 8, 2006 Posted November 8, 2006 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
webman Posted November 8, 2006 Posted November 8, 2006 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now