thummer is a website-snapshot and thumbnailing utility I am working on, built
using django. Read my previous thummer blog post
to find out more about the project.
Assumptions
In this article, I am assuming that we are installing thummer on an existing
Ubuntu server (8.04 or later) with Apache already installed, and that you are
comfortable with editing apt's sources.list file.
Step 1: Install A "Fake" X-Server
If you do not have a desktop environment installed on your server (probably a
good thing!), then you will need to install xvfb, which provides a virtual
screen so that we can capture the rendered output of the website:
Xvfb provides an X server that can run on machines with no display hardware
and no physical input devices. It emulates a dumb framebuffer using virtual
memory.
sudo apt-get install xvfb
Step 2: Install CutyCapt
We now need to install CutyCapt (webkit rendering).
First, we need to install the cutycapt dependencies and build tools:
sudo apt-get install build-essential
For hardy only: We also need some packages from hardy-backports - add the
following lines to /etc/apt/sources.list.
deb http://archive.ubuntu.com/ubuntu hardy-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu hardy-backports main restricted universe multiverse``
Now install the required qt4 packages:
sudo apt-get update
sudo apt-get install libqt4-dev libqt4-webkit libqt4-svg
It's now probably a good idea to remove (or comment out) the hardy-backports
lines from your sources.list file.
Download cutycapt source, and expand the tarball:
cd ~/
wget http://cutycapt.svn.sourceforge.net/viewvc/cutycapt/CutyCapt.tar.gz\?view\=tar
tar -xvvzf CutyCapt.tar.gz\?view\=tar
Compile cutycapt:
cd CutyCapt
qmake
make
Step 3: Install Django
First install some packages we'll need later:
sudo apt-get install python-django python-imaging python-pysqlite2 libapache2-mod-python
For hardy only: The version of django hardy ships with is too old for thummer.
Install Jaunty's version of python-django from the
updates repository by downloading the .deb file from Launchpad (remember to
keep an eye out for future security updates):
cd ~/
wget http://launchpadlibrarian.net/17665378/python-django_1.0-1ubuntu1_all.deb
sudo dpkg -i python-django_1.0-1ubuntu1_all.deb
Usage
Just use the following URL syntax to reference the image (e.g. in img
elements):
http://thummer.domainname.com/[width]/[height]/[crop]/http://url-to-capture/
the value of [crop] can either be 0 or 1, where 0 = scale & fit, and 1 = scale
& crop.
e.g. to generate a 300x300 pixel cropped thumbnail of the BBC News website:
http://thummer.domainname.com/300/300/1/http://news.bbc.co.uk/
<img src="http://thummer.domainname.com/300/300/1/http://news.bbc.co.uk/" alt="BBC News website thumbnail" />
And here is the result:
Remember you can access the admin interface by going to
http://thummer.domainname.com/admin where you can delete snapshots - so
that they are regenerated next time they are requested.