截屏的终端命令是什么?

dev*_*av2 134 command-line screenshot

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

我正在运行 Ubuntu GNOME。

小智 118

您可以使用ImageMagick 包中提供的导入工具(如果您的系统上还没有它,则需要安装它)。

在 shell 中运行以下命令:

import screenshot.png
Run Code Online (Sandbox Code Playgroud)

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

import实际上是一个非常强大的命令,它可以以多种方式用于捕获屏幕。例如,要捕获整个屏幕并经过一些延迟并调整其大小,请使用以下命令:

import -window root -resize 400x300 -delay 200 screenshot.png
Run Code Online (Sandbox Code Playgroud)

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

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

要安装 scrot类型:

sudo apt-get install scrot
Run Code Online (Sandbox Code Playgroud)

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

scrot MyScreenshot.png
Run Code Online (Sandbox Code Playgroud)

更多选项scrot在这里:

scrot -b -d 5 '%Y:%m:%d:%H:%M:%S.png' -e 'mv $f ~/Desktop/'
Run Code Online (Sandbox Code Playgroud)

在这个例子中,

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


dev*_*av2 67

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

按+ +打开终端并输入CtrlAltT

gnome-screenshot
Run Code Online (Sandbox Code Playgroud)

使用gnome-screenshot -d xx延迟操作。

将截屏动作延迟 10 秒

gnome-screenshot -d 10
Run Code Online (Sandbox Code Playgroud)

或者

sleep 10;gnome-screenshot
Run Code Online (Sandbox Code Playgroud)

  • `gnome-screenshot --help` 会给你很多选择。 (6认同)
  • `gnome-screenshot --interactive` (3认同)

Avi*_*Raj 13

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

sudo add-apt-repository ppa:shutter/ppa
sudo apt-get update
sudo apt-get install shutter
Run Code Online (Sandbox Code Playgroud)

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

shutter -a -o shot.png -e
Run Code Online (Sandbox Code Playgroud)

要截取整个显示的屏幕截图,

shutter -f -o shot.png -e
Run Code Online (Sandbox Code Playgroud)

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

有关更多选项运行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 (e.g. 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 (e.g. window title)
             $nb_name = like $name but without blanks in resulting strings
             $profile = name of current profile
             $R = random char (e.g. $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, e.g. 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.
Run Code Online (Sandbox Code Playgroud)

  • Shutter 是一个非常先进的工具,它具有像 GIMP 一样的编辑镜头,并且可以轻松添加对教程非常有用的自动增量形状。 (2认同)

chr*_*iad 8

如果你想利用从登录的终端(你打开一个截图Ctrl+ Alt+ F1),您可以使用该程序fbgrab

您可以通过键入安装它sudo apt-get install fbcat

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

$ sudo fbgrab my_screenshot
Run Code Online (Sandbox Code Playgroud)

my_screenshot保存在当前目录下。

  • `my_screenshot` 的格式是什么?如何查看? (2认同)

Chr*_*jer 8

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

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

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

xwd -silent -root | convert xwd:- screenshot.png
Run Code Online (Sandbox Code Playgroud)

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

xwd -silent -root | convert xwd:- -crop 1920x1080+0+0 test.png
Run Code Online (Sandbox Code Playgroud)

仅适用于第二个屏幕:

xwd -silent -root | convert xwd:- -crop 1920x1080+1920+0 +repage test.png
Run Code Online (Sandbox Code Playgroud)