Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copying an image to the clipboard from command line

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 ?

like image 754
qdii Avatar asked Jun 11 '12 09:06

qdii


1 Answers

Have a look at xclip, especially at xclip-copyfile and xclip-pastefile.

  xclip -i < yourfile.png
like image 195
dwalter Avatar answered Sep 23 '22 09:09

dwalter