我使用的是 Ubuntu(这是一台运行 18.04.06 的非常旧的 32 位计算机,没有更新的东西)。
当我手动打开 Gimp 时,我可以使用 编辑 > 粘贴为 > 新图像 开始处理剪贴板中的图像(例如屏幕截图)。
我的屏幕截图应用程序没有选项直接将屏幕截图存储为具有给定名称的图像文件(较新的版本确实有它,但它们在旧的 32 位 Ubuntu 上不可用)。但是屏幕截图程序有一个选项可以将屏幕截图获取到剪贴板。
我想制作一个脚本
<date and time in ISO8601-format>_Screenshot.png
)。这可能吗,还是需要一些其他控制台程序来首先将图像从剪贴板存储到文件中,例如
xclip -selection clipboard -t image/png -o > /tmp/2024-08-21T14-39-00_Screenshot.png
?
如果这
xclip
不正确,您还有什么推荐吗?
是的,可以通过将图像放入文件然后用它启动 Gimp 来实现。
1. xfce4-screenshooter -cfmd 7`# take a full screen screenshot with mouse to the clipboard
2. xclip -selection clipboard -t image/png -out > image.png # put it to the file
3. gimp image.png # call gimtp with it
一个更复杂的脚本看起来例如像这样:
#!/bin/bash
# ********************** Print_mf7_1.8.2.sh ***********************
#
# make a full screen screenshot after 7 seconds delay
#
# The result gets stored in the folder ~/Screenshots and it gets
# automatically generated names which contain ISO8601-timestamps
# (with the : repalced by -, because : can't be part of a file name
# in certain operating systems.
#
# *****************************************************************
# If the bash variable array ssTHEMA has values, a numerical
# optional parameter can select the i-th of it to be prepended
# to the date, which becomes part of the file name.
# The names in the variable array must not contain any
# characters incompatible with a file name and spaces also
# must not be present in them.
# This feature allows collecting consecutive screenshots
# for separate topics if this script is associated with different
# keyboard-shortcuts, e.g.
# Shift-Print ---> without Parameter
# Strg- Print ---> 1
# Fn- Print ---> 2
# Shift-Ctrl- Print ---> 3
# Shift-Fn- Print ---> 4
# etc.
# *****************************************************************
mkdir -p "/home/$(whoami)/Screenshots" # create folder if not existing
if [[ ${ssTHEMA} == "" ]] ;
then
ssTHEMA=(0 1 2 3 4 sonst) ; else echo "${ssTHEMA[*]}";
fi
if [[ $1 == "" ]] ;
then
ssNAME="/home/$(whoami)/Screenshots/$(\date -Iseconds | sed -e s"/T/_/" | sed -e s"/:/-/g" | cut -c1-19).png"
else
sssTHEMA=$1
if [ $1 -gt 6 ]
then
sssTHEMA=6
fi
ssNAME=""/home/$(whoami)/Screenshots/${ssTHEMA[$sssTHEMA]}"_"$(\date -Iseconds | sed -e s"/T/_/" | sed -e s"/:/-/g" | cut -c1-19).png""
fi
# 7 seconds delayed screenshot...
xfce4-screenshooter -cfmd 7 # version 1.8.2 can't --save "${ssNAME}"
xclip -selection clipboard -t image/png -out > "${ssNAME}"
gimp "${ssNAME}" # call Gimp with it