Take the 2-minute tour ×

I know there's several type of selection in Linux: primary, secondary, and clipboard, I treat the first two as short-term clipboard, and clipboard as long-term clipboard. Am I right?

Now, since the primary/secondary selection is text-only, I want to copy image to the long-term clipboard, I don't know if there is a MIME type associated with it. Because the Screen Capture is able to copy the screenshot to clipboard, so I guess there is some meta data to describe it's in image format. But commands like xsel doesn't give any option on operating image clipboard data. Neither copy image file to clipboard nor dump the image from clipboard to file is supported.

After search the google, I found there's some support in Python/Gtk:

import pygtk
import gtk
import os
def copy_image(f):
    assert os.path.exists(f), "file does not exist"
    clipboard = gtk.clipboard_get()
    img = gtk.Image()

I haven't tried it myself, because I'm not familiar with Python, but that look like at least some programs support the image clipboard.

Here is a question, since I guess the clipboard in GNOME may not have a MIME type, does most of Gnome applications share the same convention on image format?

And, what documents shall I refer to if I want to program with image clipboard to share images between different applications, for example one want 8-bit indexed bitmap and another want 24-bit RGB bitmap?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Copy & paste in Gnome performs a negotiated data transfer, one provides a list of formats available for the data and the other chooses their preferred type. APIs such as Gtk+ simplify this by only providing an interface for a GdkPixbuf and managing the format transfer itself.

Usually you are not wanting a raw bitmap transfer as it is going to be rather slow for large images, PNG compression is good but say pasting to OO.o only supports JPEG compression which you usually do not want for non-photo objects. This leads to slow pasting of images from say The Gimp to Writer.


share|improve this answer
Doesn't that famous OO.o support the famous PNG? - - –  Xiè Jìléi Dec 21 '10 at 6:31
@谢继雷 not when I implemented copy & paste in gpaint, I still have issues logged in Launchpad or somewhere about it. –  Steve-o Dec 31 '10 at 8:59
add comment

Your Answer


