Screenshot of Web Page on Linux Server

In this tutorial I will tell how to setup a server with Debian Lenny operating system to add capability for taking screenshot pictures of a web page you want.
[center][url=/media/techsiteblog/uploads/tech.jpg][img]/media/techsiteblog/uploads/tech-300×225.jpg[/img][/url][/center]

Create a shell file (for example screenshot.sh) with following script which starts the web browser, loads a page, takes a picture and closes the web browser.
[quote]#!/bin/bash
export DISPLAY=\":1\"
/usr/bin/iceweasel –display :1 \"$1\" > /dev/null 2> /dev/null &
/bin/sleep 10
/usr/bin/import -window root -display :1 \"$2\"
killall -9 /usr/lib/iceweasel/firefox-bin[/quote]
This script can be called like this:
[quote]./screenshot.sh http://www.google.com /var/www/picture_path.jpg[/quote]
Now you can take picture of any page you’d like with this simple command. It takes about 11 seconds to take 1 screenshot (script needs to sleep for about 10 seconds so that the page can load in web browser – you can change that time but is not recommended to set it bellow 5 seconds because most of the pages won’t load that quickly).

When you’re finished with taking screenshots you can kill vncserver with following command:
[quote]vncserver -kill :1[/quote]
That’s it for this tutorial. Additionally you can write PHP script which calls screenshots.sh and automatically crop picture to remove sliders and other unwanted elements on it.