54

I have a graphic on the clipboard on OS X.

What's the quickest way to get it onto disk as a png or jpg?

83

Maybe the File | New From Clipboard menu of /Application/Preview.app.

enter image description here

  • 6
    Pressing ⌘N is faster. :) – rightfold Jul 11 '11 at 21:43
  • 3
    @WTP It does show that in the image. :P I included it for that purpose. – nix Dec 19 '11 at 20:03
36

Here is a utility to do just that.

pngpaste

Paste PNG into files, much like pbpaste does for text.

However instead of pngpaste > thefile.png, it's pngpaste thefile.png, so one does not accidentally barf binary into the console.

  • 1
    That rocks. You cranked that out pretty quick. – sholsinger Mar 30 '11 at 20:54
  • You are my hero – psp Jun 3 '15 at 7:51
  • I custom a shell function to save and then select it in finder: function pngp { local path=~/Downloads/${1-000}.png pngpaste $path | open -R $path } – lingceng Dec 30 '15 at 4:12
29

If you have Preview.app open you can simply 'create new' cmd+n and that will generate the proper canvas and paste the clipboard image. Only thing left to do is save that file. Presto!

9

Not nearly as slick, but without using Preview.

Finder -> Edit -> Show Clipboard

Cmd+Shift+4 to get the screen shot marquee tool, and copy the part of the clipboard you want. It's now a PNG on your desktop. But probably not precisely the same image file.

But at that rate, you probably could have screen-captured the original source using the same method and went right to the PNG without using the clipboard.

  • Thanks for the edit Jeff... was trying to do that myself when you changed it. Never noticed that you could format the keys like that! – bpanulla Mar 30 '11 at 17:27
  • 3
    Additionally, if you add Control to the screenshot command above, it will screenshot to clipboard and not a file. I realize that's the opposite of the OPs question, but it never hurts to close the circle. – atroon Mar 30 '11 at 19:55
4

I like to use the command line:

pbpaste > myfile.png

The pbcopy command is useful as well. See this post for details.

  • 1
    I just tested it, and pbpaste only works with plain text, rich text, etc. No binary data. See this SO post – Alex Vidal Mar 30 '11 at 17:25
  • 1
    -1 as it doesn't actually work for the question he asked. – cabbey Mar 30 '11 at 17:58
  • 3
    Bummer, thought for sure it would work with binary but didn't test (mac is at home, not here at work). Got the StackOverflow urge to post something as fast as I could. Tried to downvote my own answer but I couldn't. :) – Jeremy Mullin Mar 30 '11 at 18:04
  • Oh hells yeah. This is rad -- despite the obvious failure suggested by others. – sholsinger Mar 30 '11 at 20:49
  • 3
    There's always the "delete" link! – Arjan Apr 5 '11 at 11:56
1

Using Preview.app is a way, but a little cumbersome. It can also be done on the command line.

Because pbpaste can only pbpaste > filename text snippets, you want to use pngpaste instead.

Install it with Brew:

brew install pngpaste

and use it:

pngpaste <filename>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .