I can copy image in Gimp and paste it to OpenOffice document.

How to do it (copy or paste image) from command line?

link|improve this question

64% accept rate
feedback

2 Answers

Try xclip, it reads from stdin and should allow you to do

xclip < image.jpg

to copy the image to the clipboard.

UNTESTED

link|improve this answer
-1, I don't want "???##JFIF###..." in my document. – Vi. Jun 25 '11 at 23:46
Actually I did use this a lot, and, since about last year, it doesn't work anymore. Still looking for a solution. – Drasill Jul 8 '11 at 13:35
feedback

The following python/pygtk script does the job:

#!/usr/bin/python
import gtk, pygtk
pygtk.require('2.0')
import sys, os

def copy_image(f):
    assert os.path.exists(f), "file does not exist"
    image = gtk.gdk.pixbuf_new_from_file(f)
    clipboard = gtk.clipboard_get()
    clipboard.set_image(image)
    clipboard.store()

copy_image(sys.argv[1]);

(Source: http://ubuntuforums.org/showthread.php?t=1689889)

To use this, sudo apt-get install python pygtk, paste the above code into a script, chmod +x to make executable, and you should be good to go.

link|improve this answer
Copied little png picture using this script. Can't paste it neither to OpenOffice nor into Gimp ("There is no image data in clipboard to paste"). Don't work. After copying actual picture in Gimp and using this script the buffer reverts to text that was before that. – Vi. Dec 15 '11 at 14:22
I just tried: wget http://upload.wikimedia.org/wikipedia/commons/d/d9/Test.png && ./test.py Test.png, where test.py is exactly what's pasted here. Pastes fine into Gimp. – Leo Alekseyev Dec 15 '11 at 14:34
Tried with Test.png. "There is no image data in clipboard to paste". Does it depend on running Gnome? How to debug this? I can successfully copy image in Gimp and paste in Openoffice, so in general copying works. – Vi. Dec 16 '11 at 14:04
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.