Copy image from clipboard to file

You can actually do this with xclip using -t option.

  1. See what targets are available:
$ xclip -selection clipboard -t TARGETS -o
TARGETS
image/png
text/html
  1. Note the image/png target; go ahead and get it:
$ xclip -selection clipboard -t image/png -o > /tmp/clipboard.png

Refer to the ICCCM Section 2.6.2 for further reading.

Note: xclip SVN revision 81 (from April 2010) or patches later required.


xclip doesn't work with images on my computer (svn84-4) :

$ xclip -selection clipboard -t image/png -o
Error: target image/png not available

But there is another program which take screenshot and paste it into a file, very simply : scrot :

scrot /tmp/myImage.png