While putting together some future articles I wanted to take some screen shots within LXDE, the Pi’s default graphical interface.
I considered taking them on my PC using a remote desktop connection to the Pi but I thought it might be easier to just take them directly on the Pi as I used it.
To do this I decided to use Scrot which is a command line screen capturing utility.
The installation can be completed on Raspbian using a standard apt-get call :
sudo apt-get install scrot
Start the graphical interface by typing :
Double-click the LXTerminal icon on the desktop to open a command window.
Scrot has lots of features you can use but to instantly take a basic screen shot of the whole desktop you can use :
Here is an example (click to enlarge) :
The default file name convention will give you a date, time and resolution stamped file such as “2013-10-03-221500_1920x1080_scrot.png”.
To take a screen shot after a delay use :
scrot -d 10
where 10 is the number of seconds to wait before capturing the image. The image will be saved in your default user directory (i.e. /home/pi/). To add a countdown you can use the ‘c’ option :
scrot -cd 10
To specify a file name and location you can use :
You can change the output format used by changing the file extension.
Scrot has a lot of other useful features which can be enabled with additional command line options. These include :
-h Display additional help -v Get the current version -d X Add a delay of X seconds to the capture -c Add a countdown to a delayed capture -s Allow user to specific capture area with the mouse -u Capture the current active window -q X Specify the image quality percentage X (default 75) -t X Create a thumbnail version at a specified percentage size X -e Specify a command to run after the image is capture
The -s option allow you to drag an area with the mouse to capture.
The -u option captures the current window. Combined with the -d option you can give yourself a few seconds to select the window you want to capture. In the example below I captured the LXTerminal window I was using to run Scrot :
The -t option will create a second image that is a smaller version of the main image. The thumbnail has the same file name as the main image but with “-thumb” appended on the end.
In this example we will get our capture file and a thumbnail that is 25% smaller :
scrot -t 25 myexample.jpg
The resulting files will be myexample.jpg and myexample-thumb.jpg.
Both the -e and filename parameters can take special “format specifiers”. This are replaced with data when they are encountered by Scrot.
There are two types of format specifier. Characters preceded by a ‘%’ symbol are
are interpreted by the standard strftime function. See man strftime for examples. These are commonly used to refer to dates and times.
The second kind are Scrot specific variables and are prefixed by ‘$’. The following specifiers are recognised:
$f image path/filename (ignored when used in the filename) $m thumbnail path/filename $n image name (ignored when used in the filename) $s image size (bytes) (ignored when used in the filename) $p image pixel size $w image width $h image height $t image format $$ prints a literal '$' \n prints a newline (ignored when used in the filename)
For example :
scrot '%Y-%m-%d_$wx$h_scrot.png' -e 'mv $f ~/home/pi/images/'
creates a file called something like 2013-10-03_1920x1080_scrot.png and then moves it to an images directory.