我正在使用 ImageMagick 将屏幕的一部分复制到临时文件 (something.png) 中。我现在想直接从命令行将该文件的内容粘贴到剪贴板中。
到目前为止,我的脚本如下所示:
#!/bin/bash
TMPFILE=$(mktemp)
FORMAT='.PNG'
SCREENSHOT_FILE=${TMPFILE}${FORMAT}
mv "$TMPFILE" "$SCREENSHOT_FILE"
import "$SCREENSHOT_FILE"
cat "$SCREENSHOT_FILE" | parcellite
rm "$SCREENSHOT_FILE"
Parcellite 非常适合命令行复制和粘贴,但我无法让它处理图像。我认为这不是 Parcellite 的功能。那我该怎么办呢?
就像 kan 评论的那样,QDII 想要: http://superuser.com/questions/301851/how-to-copy-a-picture-to-clipboard-from-command-line-in-linux
xclip -selection clipboard -t image/png -o > "`date '+%Y-%m-%d_%T'`.png"
或
image/jpeg
和 .jpg
对于 JPEG。
所以现在在我的
~/Dropbox/.mybashrc
上我添加了一个别名(clipboard2photo)以轻松粘贴到图像文件(也许有一天我们会在Nautilus上拥有它)。
cat (xout) | xin -t (file --mime-type (xout) | cut -d':' -f2 | tail -c +2)
与
alias xclip 'xclip -selection clip-board';
alias xin 'xclip -in';
alias xout 'xclip -out';
我正在用这个:
sleep 1; import /tmp/ss.png; xclip -selection clipboard -t image/png </tmp/ss.png
它使用
imagemagick
(import
) 和 xclip
。确保您已安装它们。