mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-26 21:30:55 +08:00
[translated] 20170215 How to take screenshots on Linux using Scrot
This commit is contained in:
parent
914f1be572
commit
de57490d6e
@ -1,331 +0,0 @@
|
||||
zpl1025
|
||||
How to take screenshots on Linux using Scrot
|
||||
============================================================
|
||||
|
||||
### On this page
|
||||
|
||||
1. [About Scrot][12]
|
||||
2. [Scrot Installation][13]
|
||||
3. [Scrot Usage/Features][14]
|
||||
1. [Get the application version][1]
|
||||
2. [Capturing current window][2]
|
||||
3. [Selecting a window][3]
|
||||
4. [Include window border in screenshots][4]
|
||||
5. [Delay in taking screenshots][5]
|
||||
6. [Countdown before screenshot][6]
|
||||
7. [Image quality][7]
|
||||
8. [Generating thumbnails][8]
|
||||
9. [Join multiple displays shots][9]
|
||||
10. [Executing operations on saved images][10]
|
||||
11. [Special strings][11]
|
||||
4. [Conclusion][15]
|
||||
|
||||
Recently, we discussed about the [gnome-screenshot][17] utility, which is a good screen grabbing tool. But if you are looking for an even better command line utility for taking screenshots, then you must give Scrot a try. This tool has some extra features that are currently not available in gnome-screenshot. In this tutorial, we will explain Scrot using easy to understand examples.
|
||||
|
||||
Please note that all the examples mentioned in this tutorial have been tested on Ubuntu 16.04 LTS, and the scrot version we have used is 0.8.
|
||||
|
||||
### About Scrot
|
||||
|
||||
[Scrot][18] (**SCR**eensh**OT**) is a screenshot capturing utility that uses the imlib2 library to acquire and save images. Developed by Tom Gilbert, it's written in C programming language and is licensed under the BSD License.
|
||||
|
||||
### Scrot Installation
|
||||
|
||||
The scrot tool may be pre-installed on your Ubuntu system, but if that's not the case, then you can install it using the following command:
|
||||
|
||||
sudo apt-get install scrot
|
||||
|
||||
Once the tool is installed, you can launch it by using the following command:
|
||||
|
||||
scrot [options] [filename]
|
||||
|
||||
**Note**: The parameters in [] are optional.
|
||||
|
||||
### Scrot Usage/Features
|
||||
|
||||
In this section, we will discuss how the Scrot tool can be used and what all features it provides.
|
||||
|
||||
When the tool is run without any command line options, it captures the whole screen.
|
||||
|
||||
[
|
||||
![Using Scrot](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/scrot.png)
|
||||
][19]
|
||||
|
||||
By default, the captured file is saved with a date-stamped filename in the current directory, although you can also explicitly specify the name of the captured image when the command is run. For example:
|
||||
|
||||
scrot [image-name].png
|
||||
|
||||
### Get the application version
|
||||
|
||||
If you want, you can check the version of scrot using the -v command line option.
|
||||
|
||||
scrot -v
|
||||
|
||||
Here is an example:
|
||||
|
||||
[
|
||||
![Get scrot version](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/version.png)
|
||||
][20]
|
||||
|
||||
### Capturing current window
|
||||
|
||||
Using the utility, you can limit the screenshot to the currently focused window. This feature can be accessed using the -u command line option.
|
||||
|
||||
scrot -u
|
||||
|
||||
For example, here's my desktop when I executed the above command on the command line:
|
||||
|
||||
[
|
||||
![capture window in scrot](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/desktop.png)
|
||||
][21]
|
||||
|
||||
And here's the screenshot captured by scrot:
|
||||
|
||||
[
|
||||
![Screenshot captured by scrot](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/active.png)
|
||||
][22]
|
||||
|
||||
### Selecting a window
|
||||
|
||||
The utility allows you to capture any window by clicking on it using the mouse. This feature can be accessed using the -s option.
|
||||
|
||||
scrot -s
|
||||
|
||||
For example, as you can see in the screenshot below, I have a screen with two terminal windows overlapping each other. On the top window, I run the aforementioned command.
|
||||
|
||||
[
|
||||
![select window](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/select1.png)
|
||||
][23]
|
||||
|
||||
Now suppose, I want to capture the bottom terminal window. For that, I will just click on that window once the command is executed - the command execution won't complete until you click somewhere on the screen.
|
||||
|
||||
Here's the screenshot captured after clicking on that terminal:
|
||||
|
||||
[
|
||||
![window screenshot captured](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/select2.png)
|
||||
][24]
|
||||
|
||||
**Note**: As you can see in the above snapshot, whatever area the bottom window is covering has been captured, even if that includes an overlapping portion of the top window.
|
||||
|
||||
### Include window border in screenshots
|
||||
|
||||
The -u command line option we discussed earlier doesn't include the window border in screenshots. However, you can include the border of the window if you want. This feature can be accessed using the -b option (in conjunction with the -u option of course).
|
||||
|
||||
scrot -ub
|
||||
|
||||
Here is an example screenshot:
|
||||
|
||||
[
|
||||
![include window border in screenshot](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/border-new.png)
|
||||
][25]
|
||||
|
||||
**Note**: Including window border also adds some of the background area to the screenshot.
|
||||
|
||||
### Delay in taking screenshots
|
||||
|
||||
You can introduce a time delay while taking screenshots. For this, you have to assign a numeric value to the --delay or -d command line option.
|
||||
|
||||
scrot --delay [NUM]
|
||||
|
||||
scrot --delay 5
|
||||
|
||||
Here is an example:
|
||||
|
||||
[
|
||||
![delay taking screenshot](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/delay.png)
|
||||
][26]
|
||||
|
||||
In this case, scrot will wait for 5 seconds and then take the screenshot.
|
||||
|
||||
### Countdown before screenshot
|
||||
|
||||
The tool also allows you to display countdown while using delay option. This feature can be accessed using the -c command line option.
|
||||
|
||||
scrot –delay [NUM] -c
|
||||
|
||||
scrot -d 5 -c
|
||||
|
||||
Here is an example screenshot:
|
||||
|
||||
[
|
||||
![example delayed screenshot](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/countdown.png)
|
||||
][27]
|
||||
|
||||
### Image quality
|
||||
|
||||
Using the tool, you can adjust the quality of the screenshot image at the scale of 1-100\. High value means high size and low compression. Default value is 75, although effect differs depending on the file format chosen.
|
||||
|
||||
This feature can be accessed using --quality or -q option, but you have to assign a numeric value to this option ranging from 1-100.
|
||||
|
||||
scrot –quality [NUM]
|
||||
|
||||
scrot –quality 10
|
||||
|
||||
Here is an example snapshot:
|
||||
|
||||
[
|
||||
![snapshot quality](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/img-quality.jpg)
|
||||
][28]
|
||||
|
||||
So you can see that the quality of the image degrades a lot as the -q option is assigned value closer to 1.
|
||||
|
||||
### Generating thumbnails
|
||||
|
||||
The scrot utility also allows you to generate thumbnail of the screenshot. This feature can be accessed using the --thumb option. This option requires a NUM value, which is basically the percentage of the original screenshot size.
|
||||
|
||||
scrot --thumb NUM
|
||||
|
||||
scrot --thumb 50
|
||||
|
||||
**Note**: The --thumb option makes sure that the screenshot is captured and saved in original size as well.
|
||||
|
||||
For example, here is the original screenshot captured in my case:
|
||||
|
||||
[
|
||||
![Original screenshot](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/orig.png)
|
||||
][29]
|
||||
|
||||
And following is the thumbnail saved:
|
||||
|
||||
[
|
||||
![thumbnail of the screenshot](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/thmb.png)
|
||||
][30]
|
||||
|
||||
### Join multiple displays shots
|
||||
|
||||
In case your machine has multiple displays attached to it, scrot allows you to grab and join screenshots of these displays. This feature can be accessed using the -m command line option.
|
||||
|
||||
scrot -m
|
||||
|
||||
Here is an example snapshot:
|
||||
|
||||
[
|
||||
![Join screenshots](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/multiple.png)
|
||||
][31]
|
||||
|
||||
### Executing operations on saved images
|
||||
|
||||
Using the tool, we can execute various operations on saved images - for example, open the screenshot in an image editor like gThumb. This feature can be accessed using the -e command line option. Here's an example:
|
||||
|
||||
scrot abc.png -e ‘gthumb abc.png’
|
||||
|
||||
Here, gthumb is an image editor which will automatically launch after we run the command.
|
||||
|
||||
Following is the snapshot of the command:
|
||||
|
||||
[
|
||||
![Execute commands on screenshots](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/exec1.png)
|
||||
][32]
|
||||
|
||||
And here is the output of the above command:
|
||||
|
||||
[
|
||||
![esample screenshot](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/exec2.png)
|
||||
][33]
|
||||
|
||||
So you can see that the scrot command grabbed the screenshot and then launched the gThumb image editor with the captured image as argument.
|
||||
|
||||
If you don’t specify a filename to your screenshot, then the snapshot will be saved with a date-stamped filename in your current directory - this, as we've already mentioned in the beginning, is the default behaviour of scrot.
|
||||
|
||||
Here's an -e command line option example where scrot uses the default name for the screenshot:
|
||||
|
||||
scrot -e ‘gthumb $n’
|
||||
|
||||
[
|
||||
![scrot running gthumb](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/exec3.png)
|
||||
][34]
|
||||
|
||||
It's worth mentioning that $n is a special string, which provides access to the screenshot name. For more details on special strings, head to the next section.
|
||||
|
||||
### Special strings
|
||||
|
||||
The -e (or the --exec ) and filename parameters can take format specifiers when used with scrot. There are two types of format specifiers. First type is characters preceded by ‘%’ that are used for date and time formats, while the second type is internal to scrot and are prefixed by ‘$’
|
||||
|
||||
Several specifiers which are recognised by the --exec and filename parameters are discussed below.
|
||||
|
||||
**$f** – provides access to screenshot path (including filename).
|
||||
|
||||
For example,
|
||||
|
||||
scrot ashu.jpg -e ‘mv $f ~/Pictures/Scrot/ashish/’
|
||||
|
||||
Here is an example snapshot:
|
||||
|
||||
[
|
||||
![example](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/f.png)
|
||||
][35]
|
||||
|
||||
If you will not specify a filename, then scrot will by-default save the snapshot in a date stamped file format. This is the by-default date-stamped file format used in scrot : %yy-%mm-%dd-%hhmmss_$wx$h_scrot.png.
|
||||
|
||||
**$n** – provides snapshot name. Here is an example snapshot:
|
||||
|
||||
[
|
||||
![scrot $n variable](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/n.png)
|
||||
][36]
|
||||
|
||||
**$s** – gives access to the size of screenshot. This feature, for example, can be accessed in the following way.
|
||||
|
||||
scrot abc.jpg -e ‘echo $s’
|
||||
|
||||
Here is an example snapshot
|
||||
|
||||
[
|
||||
![scrot $s variable](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/s.png)
|
||||
][37]
|
||||
|
||||
Similarly, you can use the other special strings **$p**, **$w**, **$h**, **$t**, **$$** and **\n** that provide access to image pixel size, image width, image height, image format, $ symbol, and give access to new line respectively. You can, for example, use these strings in the way similar to the **$s** example we have discussed above.
|
||||
|
||||
### Conclusion
|
||||
|
||||
The utility is easy to install on Ubuntu systems, which is good for beginners. Scrot also provides some advanced features such as special strings that can be used in scripting by professionals. Needless to say, there is a slight learning curve associated in case you want to use them.
|
||||
|
||||
![](https://www.howtoforge.com/images/pdficon_small.png)
|
||||
[vie][16]
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/
|
||||
|
||||
作者:[Himanshu Arora][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/
|
||||
[1]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#get-the-applicationnbspversion
|
||||
[2]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#capturing-current-window
|
||||
[3]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#selecting-a-window
|
||||
[4]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#includenbspwindow-border-in-screenshots
|
||||
[5]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#delay-in-taking-screenshots
|
||||
[6]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#countdown-before-screenshot
|
||||
[7]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#image-quality
|
||||
[8]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#generating-thumbnails
|
||||
[9]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#join-multiple-displays-shots
|
||||
[10]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#executing-operations-on-saved-images
|
||||
[11]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#special-strings
|
||||
[12]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#about-scrot
|
||||
[13]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#scrot-installation
|
||||
[14]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#scrot-usagefeatures
|
||||
[15]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#conclusion
|
||||
[16]:https://www.howtoforge.com/subscription/
|
||||
[17]:https://www.howtoforge.com/tutorial/taking-screenshots-in-linux-using-gnome-screenshot/
|
||||
[18]:https://en.wikipedia.org/wiki/Scrot
|
||||
[19]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/scrot.png
|
||||
[20]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/version.png
|
||||
[21]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/desktop.png
|
||||
[22]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/active.png
|
||||
[23]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/select1.png
|
||||
[24]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/select2.png
|
||||
[25]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/border-new.png
|
||||
[26]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/delay.png
|
||||
[27]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/countdown.png
|
||||
[28]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/img-quality.jpg
|
||||
[29]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/orig.png
|
||||
[30]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/thmb.png
|
||||
[31]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/multiple.png
|
||||
[32]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/exec1.png
|
||||
[33]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/exec2.png
|
||||
[34]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/exec3.png
|
||||
[35]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/f.png
|
||||
[36]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/n.png
|
||||
[37]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/s.png
|
@ -0,0 +1,330 @@
|
||||
如何在 Linux 系统里用 Scrot 截屏
|
||||
============================================================
|
||||
|
||||
### 文章主要内容
|
||||
|
||||
1. [关于 Scrot][12]
|
||||
2. [安装 Scrot][13]
|
||||
3. [Scrot 的使用和特点][14]
|
||||
1. [获取程序版本][1]
|
||||
2. [抓取当前窗口][2]
|
||||
3. [抓取选定窗口][3]
|
||||
4. [在截屏时包含窗口边框][4]
|
||||
5. [延时截屏][5]
|
||||
6. [截屏前倒数][6]
|
||||
7. [图片质量][7]
|
||||
8. [生成缩略图][8]
|
||||
9. [拼接多显示器截屏][9]
|
||||
10. [在保存截图后执行操作][10]
|
||||
11. [特殊字符串][11]
|
||||
4. [结论][15]
|
||||
|
||||
最近,我们介绍过 [gnome-screenshot][17] 工具,这是一个很优秀的屏幕抓取工具。但如果你想找一个在命令行运行的更好用的截屏工具,你一定要试试 Scrot。这个工具有一些 gnome-screenshot 没有的独特功能。在这片文章里,我们会通过简单易懂的例子来详细介绍 Scrot。
|
||||
|
||||
请注意一下,这篇文章里的所有例子都在 Ubuntu 16.04 LTS 上测试过,我们用的 scrot 版本是 0.8。
|
||||
|
||||
### 关于 Scrot
|
||||
|
||||
[Scrot][18] (**SCR**eensh**OT**) 是一个屏幕抓取工具,使用 imlib2 库来获取和保存图片。由 Tom Gilbert 用 C 语言开发完成,通过 BSD 协议授权。
|
||||
|
||||
### 安装 Scrot
|
||||
|
||||
scort 工具可能在你的 Ubuntu 系统里预装了,不过如果没有的话,你可以用下面的命令安装:
|
||||
|
||||
sudo apt-get install scrot
|
||||
|
||||
安装完成后,你可以通过下面的命令来使用:
|
||||
|
||||
scrot [options] [filename]
|
||||
|
||||
**注意**:方括号里的参数是可选的。
|
||||
|
||||
### Scrot 的使用和特点
|
||||
|
||||
在这个小节里,我们会介绍如何使用 Scrot 工具,以及它的所有功能。
|
||||
|
||||
如果不带任何选项执行命令,它会抓取整个屏幕。
|
||||
|
||||
[
|
||||
![使用 Scrot](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/scrot.png)
|
||||
][19]
|
||||
|
||||
默认情况下,抓取的截图会用带时间戳的文件名保存到当前目录下,不过你也可以在运行命令时指定截图文件名。比如:
|
||||
|
||||
scrot [image-name].png
|
||||
|
||||
### 获取程序版本
|
||||
|
||||
你想的话,可以用 -v 选项来查看 scrot 的版本。
|
||||
|
||||
scrot -v
|
||||
|
||||
这是例子:
|
||||
|
||||
[
|
||||
![获取 scrot 版本](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/version.png)
|
||||
][20]
|
||||
|
||||
### 抓取当前窗口
|
||||
|
||||
这个工具可以限制抓取当前的焦点窗口。这个功能可以通过 -u 选项打开。
|
||||
|
||||
scrot -u
|
||||
|
||||
例如,这是我在命令行执行上边命令时的桌面:
|
||||
|
||||
[
|
||||
![用 scrot 截取窗口](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/desktop.png)
|
||||
][21]
|
||||
|
||||
这是另一张用 scrot 抓取的截图:
|
||||
|
||||
[
|
||||
![用 scrot 抓取的图片](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/active.png)
|
||||
][22]
|
||||
|
||||
### 抓取选定窗口
|
||||
|
||||
这个工具还可以让你抓取任意用鼠标点击的窗口。这个功能可以用 -s 选项打开。
|
||||
|
||||
scrot -s
|
||||
|
||||
例如,在下面的截图里你可以看到,我有两个互相重叠的终端窗口。我在上层的窗口里执行上面的命令。
|
||||
|
||||
[
|
||||
![选择窗口](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/select1.png)
|
||||
][23]
|
||||
|
||||
现在假如我想抓取下层的终端窗口。这样我只要在执行命令后点击窗口就可以了 - 在你用鼠标点击之前,命令的执行不会结束。
|
||||
|
||||
这是我点击了下层终端窗口后的截图:
|
||||
|
||||
[
|
||||
![窗口截图](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/select2.png)
|
||||
][24]
|
||||
|
||||
**注意**:你可以在上面的截图里看到,下层终端窗口的整个显示区域都被抓去下来了,甚至包括了上层窗口的部分叠加内容。
|
||||
|
||||
### 在截屏时包含窗口边框
|
||||
|
||||
我们之前介绍的 -u 选项在截屏时不会包含窗口边框。不过,需要的话你也可以在截屏时包含窗口边框。这个功能可以通过 -b 选项打开(当然要和 -u 选项一起)。
|
||||
|
||||
scrot -ub
|
||||
|
||||
下面是示例截图:
|
||||
|
||||
[
|
||||
![截屏时包含窗口边框](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/border-new.png)
|
||||
][25]
|
||||
|
||||
**注意**:截屏时包含窗口边框同时也会增加一点额外的背景。
|
||||
|
||||
### 延时截屏
|
||||
|
||||
你可以在开始截屏时增加一点延时。需要在 --delay 或 -d 选项后设定一个时间值参数。
|
||||
|
||||
scrot --delay [NUM]
|
||||
|
||||
scrot --delay 5
|
||||
|
||||
例如:
|
||||
|
||||
[
|
||||
![延时截屏](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/delay.png)
|
||||
][26]
|
||||
|
||||
在这例子里,scrot 会等待 5 秒再截屏。
|
||||
|
||||
### 截屏前倒数
|
||||
|
||||
这个工具也可以在你使用延时功能后显示一个倒计时。这个功能可以通过 -c 选项打开。
|
||||
|
||||
scrot –delay [NUM] -c
|
||||
|
||||
scrot -d 5 -c
|
||||
|
||||
下面是示例截图:
|
||||
|
||||
[
|
||||
![延时截屏示例](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/countdown.png)
|
||||
][27]
|
||||
|
||||
### 图片质量
|
||||
|
||||
你可以使用这个工具来调整截图的图片质量,范围是 1-100 之间。较大的值意味着更大的文件大小以及更低的压缩率。默认值是 75,不过最终效果根据选择的文件类型也会有一些差异。
|
||||
|
||||
这个功能可以通过 --quality 或 -q 选项打开,但是你必须提供一个 1-100 之间的数值作为参数。
|
||||
|
||||
scrot –quality [NUM]
|
||||
|
||||
scrot –quality 10
|
||||
|
||||
下面是示例截图:
|
||||
|
||||
[
|
||||
![截屏质量](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/img-quality.jpg)
|
||||
][28]
|
||||
|
||||
你可以看到,-q 选项的参数更靠近 1 让图片质量下降了很多。
|
||||
|
||||
### 生成缩略图
|
||||
|
||||
scort 工具还可以生成截屏的缩略图。这个功能可以通过 --thumb 选项打开。这个选项也需要一个 NUM 数值作为参数,基本上是指定原图大小的百分比。
|
||||
|
||||
scrot --thumb NUM
|
||||
|
||||
scrot --thumb 50
|
||||
|
||||
**注意**:加上 --thumb 选项也会同时保存原始截图文件。
|
||||
|
||||
例如,下面是我测试的原始截图:
|
||||
|
||||
[
|
||||
![原始截图](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/orig.png)
|
||||
][29]
|
||||
|
||||
下面是保存的缩略图:
|
||||
|
||||
[
|
||||
![截图缩略图](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/thmb.png)
|
||||
][30]
|
||||
|
||||
### 拼接多显示器截屏
|
||||
|
||||
如果你的电脑接了多个显示设备,你可以用 scort 抓取并拼接这些显示设备的截图。这个功能可以通过 -m 选项打开。
|
||||
|
||||
scrot -m
|
||||
|
||||
下面是示例截图:
|
||||
|
||||
[
|
||||
![拼接截屏](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/multiple.png)
|
||||
][31]
|
||||
|
||||
### 在保存截图后执行操作
|
||||
|
||||
使用这个工具,你可以在保存截图后执行各种操作 - 例如,用像 gThumb 这样的图片编辑器打开截图。这个功能可以通过 -e 选项打开。下面是例子:
|
||||
|
||||
scrot abc.png -e ‘gthumb abc.png’
|
||||
|
||||
这个命令里的 gthumb 是一个图片编辑器,上面的命令在执行后会自动打开。
|
||||
|
||||
下面是命令的截图:
|
||||
|
||||
[
|
||||
![截屏后执行命令](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/exec1.png)
|
||||
][32]
|
||||
|
||||
这个是上面命令执行后的效果:
|
||||
|
||||
[
|
||||
![示例截图](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/exec2.png)
|
||||
][33]
|
||||
|
||||
你可以看到 scrot 抓取了屏幕截图,然后再启动了 gThumb 图片编辑器打开刚才保存的截图图片。
|
||||
|
||||
如果你截图时没有指定文件名,截图将会用带有时间戳的文件名保存到当前目录 - 这是 scrot 的默认设定,我们前面已经说过。
|
||||
|
||||
下面是一个使用默认名字并且加上 -e 选项来截图的例子:
|
||||
|
||||
scrot -e ‘gthumb $n’
|
||||
|
||||
[
|
||||
![scrot 截屏后运行 gthumb](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/exec3.png)
|
||||
][34]
|
||||
|
||||
有个地方要注意的是 $n 是一个特殊字符串,用来获取当前截图的文件名。关于特殊字符串的更多细节,请继续看下个小节。
|
||||
|
||||
### 特殊字符串
|
||||
|
||||
scrot 的 -e(或 --exec)选项和文件名参数可以使用格式说明符。有两种类型格式。第一种是以 '%' 加字母组成,用来表示日期和时间,第二种以 '$' 开头,scrot 内部使用。
|
||||
|
||||
下面介绍几个 --exec 和文件名参数接受的说明符。
|
||||
|
||||
**$f** – 让你可以使用截图的全路径(包括文件名)。
|
||||
|
||||
例如
|
||||
|
||||
scrot ashu.jpg -e ‘mv $f ~/Pictures/Scrot/ashish/’
|
||||
|
||||
下面是示例截图:
|
||||
|
||||
[
|
||||
![示例](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/f.png)
|
||||
][35]
|
||||
|
||||
如果你没有指定文件名,scrot 默认会用日期格式的文件名保存截图。这个是 scrot 的默认文件名格式:%yy-%mm-%dd-%hhmmss_$wx$h_scrot.png。
|
||||
|
||||
**$n** – 提供截图文件名。下面是示例截图:
|
||||
|
||||
[
|
||||
![scrot $n variable](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/n.png)
|
||||
][36]
|
||||
|
||||
**$s** – 获取截图的文件大小。这个功能可以像下面这样使用。
|
||||
|
||||
scrot abc.jpg -e ‘echo $s’
|
||||
|
||||
下面是示例截图:
|
||||
|
||||
[
|
||||
![scrot $s 变量](https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/s.png)
|
||||
][37]
|
||||
|
||||
类似的,你也可以使用其他格式字符串 **$p**, **$w**, **$h**, **$t**, **$$** 以及 **\n** 来分别获取图片像素大小,图像宽度,图像高度,图像格式,输入 $ 字符,以及换行。你可以像上面介绍的 **$s** 格式那样使用这些字符串。
|
||||
|
||||
### 结论
|
||||
|
||||
这个应用能轻松地安装在 Ubuntu 系统上,对初学者比较友好。scrot 也提供了一些高级功能,比如支持格式化字符串,方便专业用户用脚本处理。当然,如果你想用起来的话有一点轻微的学习曲线。
|
||||
|
||||
![](https://www.howtoforge.com/images/pdficon_small.png)
|
||||
[vie][16]
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/
|
||||
|
||||
作者:[Himanshu Arora][a]
|
||||
译者:[zpl1025](https://github.com/zpl1025)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/
|
||||
[1]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#get-the-applicationnbspversion
|
||||
[2]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#capturing-current-window
|
||||
[3]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#selecting-a-window
|
||||
[4]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#includenbspwindow-border-in-screenshots
|
||||
[5]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#delay-in-taking-screenshots
|
||||
[6]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#countdown-before-screenshot
|
||||
[7]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#image-quality
|
||||
[8]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#generating-thumbnails
|
||||
[9]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#join-multiple-displays-shots
|
||||
[10]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#executing-operations-on-saved-images
|
||||
[11]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#special-strings
|
||||
[12]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#about-scrot
|
||||
[13]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#scrot-installation
|
||||
[14]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#scrot-usagefeatures
|
||||
[15]:https://www.howtoforge.com/tutorial/how-to-take-screenshots-in-linux-with-scrot/#conclusion
|
||||
[16]:https://www.howtoforge.com/subscription/
|
||||
[17]:https://www.howtoforge.com/tutorial/taking-screenshots-in-linux-using-gnome-screenshot/
|
||||
[18]:https://en.wikipedia.org/wiki/Scrot
|
||||
[19]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/scrot.png
|
||||
[20]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/version.png
|
||||
[21]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/desktop.png
|
||||
[22]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/active.png
|
||||
[23]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/select1.png
|
||||
[24]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/select2.png
|
||||
[25]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/border-new.png
|
||||
[26]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/delay.png
|
||||
[27]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/countdown.png
|
||||
[28]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/img-quality.jpg
|
||||
[29]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/orig.png
|
||||
[30]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/thmb.png
|
||||
[31]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/multiple.png
|
||||
[32]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/exec1.png
|
||||
[33]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/exec2.png
|
||||
[34]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/exec3.png
|
||||
[35]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/f.png
|
||||
[36]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/n.png
|
||||
[37]:https://www.howtoforge.com/images/how-to-take-screenshots-in-linux-with-scrot/big/s.png
|
Loading…
Reference in New Issue
Block a user