Reputation: 12963
I am using ImageMagick to copy a portion of my screen into a temporary file (something.png). I would now like to paste the contents of this file into the clipboard directly from command line.
So far my script looks like this:
#!/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 works perfectly for command line copying and pasting, but I can’t get it to work with image. I reckon this is not a feature of parcellite. How could I do that then ?
Upvotes: 7
Views: 7426
Reputation: 4577
I am using this:
sleep 1; import /tmp/ss.png; xclip -selection clipboard -t image/png </tmp/ss.png
It uses imagemagick
(import
) and xclip
. Make sure you have them installed.
Upvotes: 0
Reputation: 1596
Like kan commented that qdii wants: 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"
Or image/jpeg
and .jpg
for JPEG.
So now on my ~/Dropbox/.mybashrc
I add an alias (clipboard2photo) to easly paste to image file (maybe someday we'll have it on Nautilus).
cat (xout) | xin -t (file --mime-type (xout) | cut -d':' -f2 | tail -c +2)
with
alias xclip 'xclip -selection clip-board';
alias xin 'xclip -in';
alias xout 'xclip -out';
Upvotes: 1