Take screenshots of websites from command line in Linux

October 23, 2012 · Posted in Development 

There are several ways to take screenshots in Linux. Most of them produce a WebKit, Gecko (Firefox) or khtml rendered screenshot image. Some of the methods require X session to open a window and take screenshots.

Read how to take screenshots from command line in Windows in this my post.

gnome-screenshot (in Ubuntu Linux)

From the command-line, just type the command

gnome-screenshot

The command will take a screenshot and provide a dialog to save it.

Take the screenshot of the current active window alone:

gnome-screenshot -w

 

ImageMagick

You can use import command line tool of ImageMagick.

To install ImageMagick on Ubuntu Linux:

apt-get install imagemagick

Use the “-window root” option to take screenshot of the complete screen:

import -window root images/my1.png

 

wkhtmltopdf

http://code.google.com/p/wkhtmltopdf/

wkhtmltopdf is a command line utility that generates a pdf file from a webpage using webkit rendering engine.

 

wkhtmltoimage

http://code.google.com/p/wkhtmltopdf/downloads/list

The wkhtmltoimage takes a screenshot and saves it as a png image. It uses the webkit rendering engine.

The tool is created by the same team as wkhtmltopdf.

Cannot render flash animations. Sometimes it fails because of unknown reasons showing errors like:

 

cutycapt

http://cutycapt.sourceforge.net/

Cutycapt is a utility to take the screenshot of a url, using the webkit rendering engine and save it to an image file.

 

khtml2png

http://khtml2png.sourceforge.net/index.php?page=download

khtml2png uses the konqueror rendering engine to create screenshots of web pages.

 

python-webkit2png

http://www.blogs.uni-osnabrueck.de/rotapken/2008/12/03/create-screenshots-of-a-web-page-using-python-and-qtwebkit/

https://github.com/AdamN/python-webkit2png/

 

PyWebShot

http://www.coderholic.com/pywebshot-generate-website-thumbnails-using-python/

https://github.com/coderholic/PyWebShot

Pywebshot uses python bindings embedded mozilla ( http://www.mozilla.org/unix/gtk-embedding.html )

 

 

Read more:

- a list of tools with the instructions how to install and use them:

http://www.binarytides.com/take-webpage-screenshot-from-command-line-in-ubuntu-linux/

- 4 Methods to Take Screenshot Capture in Ubuntu Linux -

http://www.thegeekstuff.com/2012/08/screenshot-ubuntu/

 

Discussions on StackOverflow:

- http://stackoverflow.com/questions/125951/command-line-program-to-create-website-screenshots-on-linux

 

Comments

  • http://maxivak.com/take-screenshots-from-command-line-in-windows/ Take screenshots of websites from command line in Windows : Max Ivak Personal Site

    [...] If you are looking for command line tools in Linux – read this post. [...]

  • http://maxivak.com/taking-screenshots-of-websites-with-php/ Taking Screenshots of Websites with PHP : Max Ivak Personal Site

    [...] There are many command lines tools you can use to take a screenshots of a web page. See the list of tools here: in Windows, in Linux. [...]

  • http://maxivak.com/take-screenshots-of-websites-from-command-line-and-programmatically-with-php-or-net/ Take screenshots of websites from command line and programmatically with PHP or .NET : Max Ivak Personal Site

    [...] – Linux command line tools to take screenshots [...]