I have a graphic on the clipboard on ubuntu.
What's the quickest way to get it onto disk as a png or jpg?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.
Sign up to join this communityxclip
(man page) is on official repos of major distros (pasteimg
it isn't and last update was on 2011).
For me the quickest way is using terminal, going to the desired folder (maybe using Z) and then just run clipboard2photo
, which is an alias I created to the following command:
xclip -selection clipboard -t image/png -o > "$(date +%Y-%m-%d_%T).png" # Use "Screenshot from $(date "+%Y-%m-%d %H-%M-%S").png" if you like GNOME filename format.
With something on clipboard you can get all possible targets with: xclip -selection clipboard -o -t TARGETS
.
GNOME v44 let you paste directly from clipboard to Files/Nautilus.
On GNOME Shell (Ubuntu 17.10+) we have built in shortcuts to save screenshots directly to ~/Pictures
:
Hints to remember them:
~/Pictures
)I usually disable "Print" to avoid generating garbage on ~/Pictures if I miss F12 (which I use a lot with Guake) and accidentally press it.
Tip 1: Put your aliases on ~/Dropbox/.mybashrc
(or maybe better .myprofile
) and then include this file from .bashrc
.
[ -r ~/Dropbox/.mybashrc ] && source ~/Dropbox/.mybashrc
This way you will have them on all your current and future devices. Of course, you can also have a ~/.dotfiles
with a git repo.
Tip 2: In the same way, you can: thisOutputMarkdown | pandoc -s -f markdown -t html | xclip -selection clipboard -t text/html
to get formatted HTML to clipboard.
If you have the Markdown text on clipboard replace thisOutputMarkdown with xsel -b
.
It seems there is some work to be done about xclip on Wayland (echo $XDG_SESSION_TYPE
). Please help developers on this issue. Meanwhile, maybe wl-paste
(from wl-clipboard) might work:
wl-paste -t image/png > "$(date +%Y-%m-%d_%T).png"
I just threw together a quick python script that will paste a clipboard image to a file.
It's very basic but it does the job but could be easily extended.
With Gimp.
Ctrl+Shift+V
"creates" a new image from the one in the clipboard.
Ctrl+Shift+E
"exports" it, in other words it offers a "save" kind of dialog box for formats other than .xcf
.
Ah: you ask "quickest"?! Weellll, maybe if you already have Gimp open on the desktop ;)
I've been googling for a while and it seems as if there is no clipboard manager yet that supports pasting of an image directly in a folder, even though there is this Nautilus feature request.
So the answer would be paste it in a graphics application (e.g. gimp) and save it.
I've created pimg to replace PasteImg. It runs on Python>=3.5 with PyGObject. (Successor to PyGTK used by PasteImg)
pimg
can install via pip:
pip install pimg
Like PasteImg, it runs:
pimg image.png
Please try it.
I needed this for my Emacs org-download-screenshot setup, so here's a Python script I made that depends only on Python 3.8 (no additional packages), xclip and ImageMagick convert: https://github.com/cpbotha/save_image_from_clipboard
It will save out whatever image you have in the clipboard, to whatever format you specify on the command-line.
xclip wasn't working for me and I coudn't understand why until I realized that if you are running Wayland, for example in Ubuntu 21.04, you can't use xclip. You have to use wl-paste from the wl-clipboard package. For example:
wl-paste -t image/png > filename.png