截屏的终端命令是什么?

我可以在终端中使用哪些命令等同于PrtSc (打印屏幕)按钮?

我正在运行Ubuntu GNOME。

您可以使用ImageMagick包中提供的导入工具(如果您的系统上已无法使用,则需要安装此工具)。

在shell中运行以下命令:

 import screenshot.png 

并选择要捕获的窗口或通过按鼠标左键并拖动来选择区域。

import实际上是一个非常强大的命令,可以通过多种方式捕获屏幕。 例如,要捕获整个屏幕并在延迟并resize后,请使用以下命令:

 import -window root -resize 400x300 -delay 200 screenshot.png 

要查看import命令可用的所有选项,请访问ImageMagick的网站 。

从终端截取屏幕截图的另一种方法是使用scrot

要安装scrot类型:

 sudo apt-get install scrot 

要使用scrot类型从终端在Linux中截取屏幕截图:

 scrot MyScreenshot.png 

scrot更多选项在这里:

 scrot -b -d 5 '%Y:%m:%d:%H:%M:%S.png' -e 'mv $f ~/Desktop/' 

在这个例子中,

  • -b指定包括窗口边框
  • -d指定延迟五秒
  • ‘%Y:%m:%d:%H:%M:%S.png’将根据当前日期和时间以及指定的格式保存屏幕截图,在这种情况下为.png
  • -e’mv -e 'mv $f ~/Desktop/'告诉scrot将屏幕截图保存到桌面

在此处找到此选项,还列出了其他选项。

Ctrl + Alt + T打开终端并键入

 gnome-screenshot 

使用gnome-screenshot -d xx来延迟动作。

将屏幕截图操作延迟10秒

 gnome-screenshot -d 10 

要么

 sleep 10;gnome-screenshot 

您可以使用快门程序从终端截取屏幕截图。在终端中运行以下命令安装快门,

 sudo add-apt-repository ppa:shutter/ppa sudo apt-get update sudo apt-get install shutter 

要截取活动窗口的屏幕截图,

 shutter -a -o shot.png -e 

截取整个显示屏的截图

 shutter -f -o shot.png -e 

拍摄的屏幕截图存储在目录中。

有关更多选项,请运行shutter --help命令,

 Usage: shutter [options] Options: Example 1 shutter -a -p=myprofile --min_at_startup Example 2 shutter -s=100,100,300,300 -e Example 3 shutter --window=.*firefox.* Example 4 shutter --web=http://shutter-project.org/ -e Capture Mode Options: -s, --select=[X,Y,WIDTH,HEIGHT] Capture an area of the screen. Providing X,Y,WIDTH,HEIGHT is optional. -f, --full Capture the entire screen. -w, --window=[NAME_PATTERN] Select a window to capture. Providing a NAME_PATTERN (Perl-style regex) ist optional. -a, --active Capture the current active window. --section Capture a section. You will be able to select any child window by moving the mouse over it. -m, --menu Capture a menu. -t, --tooltip Capture a tooltip. --web=[URL] Capture a webpage. Providing an URL ist optional. -r, --redo Redo last screenshot. Settings Options: -p, --profile=NAME Load a specific profile on startup. -o, --output=FILENAME Specify a filename to save the screenshot to (overwrites any profile-related setting). Supported image formats: You can save to any popular image format (eg jpeg, png, gif, bmp). Additionally it is possible to save to pdf, ps or svg. Please note: There are several wildcards available, like %Y = year %m = month %d = day %T = time $w = width $h = height $name = multi-purpose (eg window title) $nb_name = like $name but without blanks in resulting strings $profile = name of current profile $R = random char (eg $RRRR = ag4r) %NN = counter The string is interpretted by strftime. See "man strftime" for more examples. As an example: shutter -f -e -o './%y-%m-%d_$w_$h.png' would create a file named '11-10-28_1280_800.png' in the current directory. Application Options: -h, --help Prints a brief help message and exits. -v, --version Prints version information. -d, --debug Prints a lot of debugging information to STDOUT. --clear_cache Clears cache, eg installed plugins, at startup. --min_at_startup Starts Shutter minimized to tray. --disable_systray Disables systray icon. -e, --exit_after_capture Exit after the first capture has been made. This is useful when using Shutter in scripts. 

我尝试使用ImageMagick import但在使用KDE桌面效果时它对我不起作用。 ImageMagick import输出透明窗口边框为黑色,而不是正确组合前景alpha和背景。

我也试过使用X11 xwdNetPBM xwdtopnm但这对我来说也不起作用, NetPBM xwdtopnm无法正确处理xwd的多屏幕输出,因为我有一个Xinerama设置。

但是将X11 xwdImageMagick convert相结合对我来说效果很好:

 xwd -silent -root | convert xwd:- screenshot.png 

或者,如果您有像我这样的Dual-FullHD Xinerama设置,并且只想要第一个屏幕:

 xwd -silent -root | convert xwd:- -crop 1920x1080+0+0 test.png 

仅限第二个屏幕:

 xwd -silent -root | convert xwd:- -crop 1920x1080+1920+0 +repage test.png 

如果你想从登录终端(用Ctrl + Alt + F1打开的那个)截取屏幕截图,你可以使用程序fbgrab

您可以通过输入sudo apt-get install fbcat来安装它。

然后获取登录终端的屏幕截图,输入您的登录终端:

 $ sudo fbgrab my_screenshot 

my_screenshot保存在当前目录下。

我正在使用ubuntu 13.10并且我有一个我刚写的脚本可能会有所帮助。 我看到这些问题已得到解答,但我的解决方案无需额外安装。

 #!/bin/bash curDate=$(date) imgExtension=".png" imgName=$curDate$imgExtension imgDirectory="/path/to/desires/save/directory/" imgSavePath=$imgDirectory$imgName gnome-screenshot --file="$imgSavePath" 

此代码将保存屏幕截图,而不会弹出对话窗口。 它使用文件名的当前时间来避免任何重复的文件名问题。