What is a good command line tool to create screenshots of websites on Linux? I need to automatically generate screenshots of websites without human interaction. The only tool that I found was khtml2png, but I wonder if there are others that aren't based on khtml (i.e. have good JavaScript support, ...).
-
has some more... – Stobor Jul 07 '09 at 05:39
-
Another quick way to do it is use shutter: Install: *$apt-get install shutter* Run: *$shutter --web=http://mail.ru -e*' – 0x8BADF00D Jul 30 '14 at 20:34
-
1On-topic here: http://softwarerecs.stackexchange.com/questions/16422/no-gui-tool-to-take-screenshots-of-websites – Nicolas Raoul Sep 11 '15 at 06:04
10 Answers
A little more detail might be useful...
Start a firefox (or other browser) in an X session, either on your console or using a vncserver. You can use the --height
and --width
options to set the size of the window to full screen. Another firefox command can be used to set the URL being displayed in the first firefox window. Now you can grab the screen image with one of several commands, such as the "import" command from the Imagemagick package, or using gimp, or fbgrab, or xv.
#!/bin/sh
# start a server with a specific DISPLAY
vncserver :11 -geometry 1024x768
# start firefox in this vnc session
firefox --display :11
# read URLs from a data file in a loop
count=1
while read url
do
# send URL to the firefox session
firefox --display :11 $url
# take a picture after waiting a bit for the load to finish
sleep 5
import -window root image$count.jpg
count=`expr $count + 1`
done < url_list.txt
# clean up when done
vncserver -kill :11

- 671
- 3
- 9

- 2,090
- 14
- 14
-
1This worked nice, except for firefox the `-display :11` needed to be `--display=:11` But you gave me a great starting point! Thanks for that! – Jim Nov 05 '10 at 15:12
-
Very nice. Need more info though. Like with the --display option. How did you know that? Where is the documentation for doing this. Reason is, I need the program to open full screen. When I get a screenshot Firefox is not full screen but in a resizable smaller window. – shrimpwagon Jun 14 '13 at 20:44
-
This should be redirected to: [No-GUI tool to take screenshots of websites](https://softwarerecs.stackexchange.com/q/16422/25142) – marcanuy May 15 '17 at 12:56
-
5
-
2CutyCapt is an awesome tool, but I used @font-face fonts, and they didn't get displayed correctly. – MarcDefiant Apr 15 '13 at 19:50
-
-
1Sometime CutyCapt produces "segfaults", i cannot rely on it in a production environment! – Ma'moon Al-Akash Jul 28 '15 at 10:07
-
2
Have a look at PhantomJS, which seems to be a free scritable Webkit engine that runs on Linux, OSX and Windows. I've not used it since we currently use Browshot (commercial solution), but when all our credits run out, we will seriously have a loot at it (since it's free and can run on our servers)

- 6,133
- 6
- 47
- 76
-
I just tried this (phantomjs) on my hostmonster account, a "if it works here it can work anywhere" environment. 1. download tarball 2. untar tarball 3. go to bin directory 4. cut and paste hello world example from their quick start page. 5. run hellow world – godzilla Jan 11 '15 at 20:27
-
(cont from last post) 6. wait a few minutes (I thought that it locked up but it just took awhile for the 1st time). 6 cut and past the example below helloWorld.js 7. change example.com to site you want the screenshot. 8. run example the 5 minutes I took to do this was a lot less pain than tring to get webkit2png working, thanx MaxiWheat sorry for 2 seperate post, edit timer ran out – godzilla Jan 11 '15 at 20:38
scrot is a command line tool for taking screenshots. See the man page and this tutorial.
You might also want to look at scripting the browser. There are firefox add-ons that take screenshots such as screengrab (which can capture the entire page if you want, not just the visible bit) and you could then script the browser with greasemonkey to take the screenshots.

- 16,603
- 16
- 90
- 84
See Webkit2png.
I think this is what I used in the past.
Edit I discover I haven't used the above, but found this page with reviews of many different programs and techniques.

- 3,125
- 27
- 31
I know its not a command line tool but you could easily script up something to use http://browsershots.org/ Not that useful for applications not hosted on external IPs.
A great tool none the less.

- 16,574
- 12
- 50
- 83
-
Actually I think I can just use the code from this project to write my own local version instead of submitting stuff through browsershots.org (because it's for a company). – ujh Sep 24 '08 at 08:40
I don't know of anything custom built, I'm sure there could be something done with the gecko engine to render to a png file instead of the screen ...
Or, you could fire up firefox in full screen mode in a dedicated VNC server instance and use a screenshot grabber to take the screenshot. Fullscreen = minimal chrome, VNC server instance = no visible UI + you can choose your resolution.
Use xinit with Xvnc as the X server to do this - you'll need to read all the manpages.
Downsides are that the screenshot is always the same size, doesn't resize according to the web page ...

- 12,336
- 5
- 29
- 43
There is the import command, but you'll need X, and a little bash script that open the browser window, then take the screenshot and close the browser.
You can find more information here, or just typing import --help in a shell ;)

- 38,188
- 14
- 54
- 77
http://khtml2png.sourceforge.net/
The deb file
worked on my Ubuntu after installing libkonq4 ... but you may have to cover other dependencies.
I think javascript support may be better now!
Stephan

- 246
- 2
- 4
Not for the command line but at least for usage in batch operation for a larger set of urls you may use firefox with its addon fireshot (licensed version?).
- Open tabs for all urls in your set (e.g. "open tabs for all bookmarks in this folder...").
- Then in fireshot launch "Capture all tabs"
- In the edit window then call "select all shots -> save all shots"
Having set the screenshot properties (size, fileformat, etc.) before you end with a nice set of shotfiles.
Steffen

- 51
- 3