User Tools

Site Tools


websitethumbs

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
websitethumbs [2005/11/06 15:31] stanwebsitethumbs [2008/06/16 18:16] (current) 82.69.46.186
Line 1: Line 1:
 +====== 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 [[http://www.opera.com|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 =====
 +
 +<code bash>
 +#!/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
 +</code>