Linux下截图软件Scrot的安装

本文详细介绍了在CentOS 7.6环境下,如何解决安装scrot截图工具时遇到的依赖库缺失问题,包括giblib和imlib2的安装步骤。并提供了scrot的常用命令和高级用法,如延时截图、生成缩略图等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

scrot的安装

安装环境

系统CentOS 7.6
1.# wget http://fossies.org/unix/privat/scrot-0.8.tar.gz 
2.# tar xvf scrot-0.8.tar.gz  
3.# cd scrot-0.8  
4.# ./configure  下面出现错误

[root@localhost scrot-0.8]# ./configure 
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking whether make sets $(MAKE)... yes
checking for working aclocal-1.4... missing
checking for working autoconf... found
checking for working automake-1.4... missing
checking for working autoheader... found
checking for working makeinfo... found
checking for gcc... gcc
checking for C compiler default output... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking for gcc option to accept ANSI C... none needed
checking for an ANSI C-conforming const... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking whether make sets $(MAKE)... (cached) yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking for giblib-config... no
checking for giblib - version >= 1.2.3... no
*** The giblib-config script installed by giblib could not be found
*** If giblib was installed in PREFIX, make sure PREFIX/bin is in
*** your path, or set the GIBLIB_CONFIG environment variable to the
*** full path to giblib-config.
configure: error: Cannot find giblib: Is giblib-config in the path?

提示缺少giblib
1.# wget http://linuxbrit.co.uk/downloads/giblib-1.2.4.tar.gz  
2.或者是下面的链接  
3.# wget http://pkgs.Fedoraproject.org/repo/pkgs/giblib/giblib-1.2.4.tar.gz/c810ef5389baf24882a1caca2954385e/giblib-1.2.4.tar.gz  
4.# tar zxvf  giblib-1.2.4.tar.gz 
5.# cd giblib-1.2.4
 
6.#./configure 继续提示错误

checking whether to build static libraries... yes
checking for f95 option to produce PIC... -fPIC
checking if f95 PIC flag -fPIC works... yes
checking if f95 supports -c -o file.o... yes
checking whether the f95 linker (/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking whether make sets $(MAKE)... (cached) yes
checking whether build environment is sane... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking if malloc debugging is wanted... no
checking for imlib2-config... no
checking for imlib2 - version >= 1.0.0... no
*** The imlib2-config script installed by imlib2 could not be found
*** If imlib2 was installed in PREFIX, make sure PREFIX/bin is in
*** your path, or set the IMLIB2_CONFIG environment variable to the
*** full path to imlib2-config.
configure: error: Cannot find imlib2: Is imlib2-config in the path?

提示缺少imlib2,遂下载安装之,则OK。

 

安装顺序记录如下,


1.######################imlib########################  
2.wget http://sourceforge.net/projects/enlightenment/files/imlib2-src/1.4.5/imlib2-1.4.5.tar.gz/download    
3.tar xvf imlib2-1.4.5.tar.gz      
4.cd imlib2-1.4.5      
5../configure      

这里会显示报错

api.c:5:34: fatal error: X11/extensions/shape.h: No such file or directory

执行 yum install xorg-x11* -y 就行
6.make      
7.make install     
8.########################giblib#####################  
9.wget http://linuxbrit.co.uk/downloads/giblib-1.2.4.tar.gz  
10.cd giblib-1.2.4    
11../configure   
12.make    
13.make install  
14.########################scrot#######################  
15.wget http://fossies.org/unix/privat/scrot-0.8.tar.gz  
16.tar xvf scrot-0.8.tar.gz    
17.cd scrot-0.8     
18../configure  
19.make  
20.make install  
21.#########################over##################### 

安装完毕,问题还未结束
1.#scrot 运行scrot命令,如下提示libgiblib的库没有找到  
2.scrot: error while loading shared libraries: libgiblib.so.1: cannot open shared object file: No such file or directory  
3.在系统里面寻找libgiblib库文件  
4.#find /usr -name libgiblib.so.1  
5./usr/local/lib/libgiblib.so.1  
6.#cat /etc/ld.so.conf  查看当前库加载路径  
7.include ld.so.conf.d/*.conf  
8.#echo "/usr/local/lib" >> /etc/ld.so.conf 添加库路径  
9.#ldconfig  加载库文件后scrot正常使用

 

使用教程

 


10.#scrot --help 查看scrot的帮助信息  
11.Usage : scrot [OPTIONS]... [FILE]  
12.  Where FILE is the target file for the screenshot.  
13.  If FILE is not specified, a date-stamped file will be dropped in the  
14.  current directory.  
15.  See man scrot for more details  
16.  -h, --help                display this help and exit  
17.  -v, --version             output version information and exit  
18.  -b, --border              When selecting  
19.…… 

scrot的使用方法

scrot 的使用格式为:scrot [options] [file]。

一般用法

就一般而言,使用 scrot 可以抓取整个桌面、某个指定的窗口、以及选择的矩形区域。

抓取桌面:scrot desktop.png,该命令将当前的整个桌面抓取下来,并保存为 desktop.png 文件。可以在当前的目录中找到此图像文件。

抓取窗口:scrot -bs window.png,选项 b 使 scrot 在抓取窗口时一同将外边框抓取下来,而 s 选项则让用户选择所要抓取的是何窗口。

抓取区域:scrot -s rectangle.png,在执行此命令后,使用鼠标拖曳的矩形区域将被 scrot 抓取下来。

高级使用

对于普通的抓取使用 scrot 的基础便足以应付了。但在某些特殊情况之下,使用 scrot 抓取图像需要讲究一些技巧。

延时抓取:scrot -cd 10 menu.png,此命令中的 d 选项用于延时抓取图像,其后的 10 代表延时 10 秒;前面的选项 c 显示倒计时。在抓取菜单或是命令提示时,该技巧将充分展示其魔力。

生成缩图:scrot -t 50% thumb.png,这个命令在抓取图像的同时生成该图像的缩略图。选项 t 将打开此功能,其后的 50% 为原图的缩放百分比。

更改品质:scrot -q 70 quality.jpg,此命令中的 q 选项用于更改所抓图像的品质,其数值介于 1-100 之间,默认为 75。数值越大,意味着图像品质越高;同时,图像的压缩率也就越低,占用空间越大。

操作抓图:scrot action.png -e 'mv $f ~/images/',该命令将抓取的图像移动到 ~/images/ 目录。显然,操作图像的功能由 e 选项开启,其中的 $f 代表原图的路径/文件名。

以上示例皆指定了需要保存的抓图的文件名称。实际上,如果不指定名称,那么 scrot 在抓取图像后会自动使用当前的日期时间、宽度高度的组合来生成文件名称。

传个图片看一下抓图效果,

打开查看如下

似乎有一点遗憾的是不能支持粘贴功能,只能把文件保存为图片,不过可以满足日常用了。

 另一个截屏软件是import

几个常用的import命令:

1 import my.jpg

然后可以使用鼠标选择的范围

2 sleep 5; import my.jpg

等待5秒钟后,截取鼠标选择的范围

3 import -frame my.jpg

截取鼠标所点击的窗口

4 import -window root my.jpg

截取整个屏幕,作用相当于Print Screen键

5 import -frame -window 0xe00003 mypicture.jpg

用于截取window ID为0xe00003的窗口。

你可以使用xwininfo命令获取到特定窗口的window ID

ps:截取完成的图片,如果你想了解它的各项参数,可以使用identify命令加图片文件名称就可以了。

本篇文章来源于 Linux公社网站(www.linuxidc.com)  原文链接:https://www.linuxidc.com/Linux/2012-07/64145p2.htm

本篇文章来源于 Linux公社网站(www.linuxidc.com)  原文链接:https://www.linuxidc.com/Linux/2012-07/64145.htm

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值