Here are the steps to setup a linux headless display server to take screenshots of websites using http://cutycapt.sourceforge.net/ and Xvfb. This example is using ubuntu 10.10 64bit.
*this assumes you have cutycapt installed and working – as well as Xvfb
- If your taking multiple screenshots (like as a service for example) you’ll want to run Xvfb as a service. Create the following file in /etc/init.d/screencap
- Make it so it runs at startup
sudo update-rc.d screencap defaults
sudo chmod 700 /etc/init.d/screencap
- Now you can restart, or run:
sudo /etc/init.d/screencap start
- Now from another terminal take the screenshot: DISPLAY=:1 /usr/bin/CutyCapt –url=”http://rynop.com” –out=”rynop.jpg” –out-format=jpeg –plugins=off –delay=4000
So why not use xvfb-run? I intend to take multiple screenshots, so starting Xvfb before every screenshot, then killing (which xvfb-run does) it alot of wasted overhead. I see the Xvfb process only takes up ~ 7megs of memory – so its not really all that bloated.
Taking screenshots is pretty slow, as you have to wait for page to render. If anyone has tips on how to improve performance please let me know.
Extra credit – monitor the service with monit
- Create the following file: /etc/monit/conf.d/screencap.monitrc
- Run /etc/init.d/monit restart