Source: http://jerel.co/blog/2010/10/using-firefox-on-a-headless-server-to-make-screenshots-of-websites
apt-get install xvfb firefox imagemagick
Xvfb :1 -screen 0 1280x960x24 &
DISPLAY=:1 firefox http://www.alain.fi &
DISPLAY=:1 import -window root -crop 622x948+68+71 -resize 600x400 -quality 90 /var/www/screenshots/screenshot.jpg