Forum Moderators: open
One tricky part of this method would be determining when rendering was complete. However, you could simply monitor the status bar looking for the word 'Done'. You could also monitor traffic.
I doubt that a unique rendering engine is used to take snapshots.
Kaled.
Script to generate thumbnail [webmasterworld.com]
#4
mattx17:One way you can do it is you have a browser such as mozilla installed on the server, and you also have X running (and a window manager), you can get a screenshot this way:
Leave the browser window open, fully maximized, in your server's X session. Run the command (from your script):
mozilla -remote openURL('http://www.mysite.com')
This should open the URL up in the servers X session. Once that is done, take a screen shot with any of the available tools for X. We'll use xwd as an example:
xwd -frame -root -out myscreenshot.xwd
This will take a full screenshot of the X root window, which should have the browser window open at that URL.
After that, you may have to use ImageMagick or NetPBM to convert the file into something usable for the web.
Hope this helps, even if it just points you in the right direction.
I still just wonder if there is just a simple perl/php solution available
Try this:
<?
// this script creates a thumbnail image from an image file - can be a .jpg .gif or .png file
// where $thumbsize is the maximum width or height of the resized thumbnail image
// where this script is named resize.php
// call this script with an image tag
// <img src="/php/resize.php?path=imagepath"> where path is a relative path such as subdirectory/image.jpg
$thumbsize = 200;
$imagesource = $_GET['path'];
$filetype = substr($imagesource,strlen($imagesource)-4,4);
$filetype = strtolower($filetype);
if($filetype == ".gif") $image = @imagecreatefromgif($imagesource);
if($filetype == ".jpg") $image = @imagecreatefromjpeg($imagesource);
if($filetype == ".png") $image = @imagecreatefrompng($imagesource);
if (!$image) die();
$imagewidth = imagesx($image);
$imageheight = imagesy($image);
if ($imagewidth >= $imageheight) {
$thumbwidth = $thumbsize;
$factor = $thumbsize / $imagewidth;
$thumbheight = $imageheight * $factor;
}
if ($imageheight >= $imagewidth) {
$thumbheight = $thumbsize;
$factor = $thumbsize / $imageheight;
$thumbwidth = $imagewidth * $factor;
}
$thumb = @imagecreatetruecolor($thumbwidth,$thumbheight);
imagecopyresized($thumb, $image, 0, 0, 0, 0, $thumbwidth, $thumbheight, $imagewidth, $imageheight);
imagejpeg($thumb);
imagedestroy($image);
imagedestroy($thumb);
?>
[webmasterworld.com...]
jollymcfats shares another solution in Message #4 of that thread: using Xvfb - an optional package in most Linux distributions, usually with names like xorg-x11-Xvfb or XFree86-Xvfb.
Whenever I come across a site/page that I'm interested in, I highlight the part of the page Im interested in and send it to surfulater. It then creates a thumbnail image of that page and paste the highlighted html into the app.
Great tool.
View the page at a very high resolution so you can get most of the page on one screen then use the screenshot command. Someone else posted the Window's command above; on the Mac it's (Command-shift-3 or Command-control-shift-3 puts it into the clipboard so you can paste it into your image program).
Windows 2000 had the facility built in to view webpages as thumbnails. It is possible to hook into that facility using Visual Basic.
You need to have the HTML rendered and not just the 'View Source' HTML - that way any Javascript/css can be applied. Again Visual Basic provides an interface to Internet Explorer as well as reading a database of the thousands of pages you want to generate thumbnails for. You would need to be a decent VB programmer to go this route (or C++ or Delphi).
I have done this in 2000 but I haven't tried it with Windows XP - XP doesn't display thumbnails of webpages (but the underlying calls MAY still exist)
I have done this in 2000 but I haven't tried it with Windows XP - XP doesn't display thumbnails of webpages (but the underlying calls MAY still exist)
yes it does, view a folder with html files as thumbnails and they will be displayed. It just doesn't render them in the side bar like 2000 did. I assume whatever solution you came up with on win2k would also work on XP.
But the key issue is I want to generate screen shot by reading HTML, instead of from an existed image.
You know of course your server must have PHP installed and you either must be parsing HTML pages for PHP or name your pages with the .php extension.