User Tools

Site Tools


websitethumbs

Website Thumbnails

Sometimes you may want to create thumbnail previews of some webpages (eg. for a link list). Instead of doing this manually you can script it, too.

The following script need the Opera browser (you should be able to reproduce this with any other Linux Browser) and Xvfb.

To install the latter on Debian:

#> apt-get install xvfb

Create a file named urls.txt with one URL per line. Then run the script below like this:

$> xvfb-run -s '-screen 0 1024x768x24' ./webthumb.sh

webthumb.sh

#!/bin/sh
 
URLS=urls.txt
IMAGES=images
mkdir -p $IMAGES
 
echo "starting opera..."
opera -geometry 1024x768+0+0 -nosplash &
sleep 20
echo "done."
 
for url in `cat $URLS`
do
  md5=`echo -n "$url"|md5sum|awk '{print $1}'`
  img="$IMAGES/$md5.jpg";
  if [ -e "$img" ]
  then
    #nothing
    echo -n ''
  else
    echo "$url"
    opera -remote "openURL($url)"
    sleep 7
    xwd -root -screen |xwdtopnm |pnmcut 4 170 1020 594|pnmscale -xysize 170 170 |pnmtojpeg>$img
    echo "$img created"
  fi
done
websitethumbs.txt · Last modified: 2008/06/16 20:16 by 82.69.46.186