Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Current use case:

  1. I select "copy image" on some random png in safari.
  2. I type pbpaste into terminal, and get the link to the image.

Is there anyway to get the binary data instead?

share|improve this question

When you copy an image, OS X actually doesn't copy just the raw image data. In fact, there exist multiple pasteboards in Cocoa, in which there are multiple representations of your image.

Your only options with pbpaste are to choose which pasteboard to access, but not which type of content. While the raw hexadecimal NSData is stored somewhere in the pasteboard to be pasted to image editing tools, you can't pbpaste it to a terminal which would only accept text. From the pbpaste manpage:

It normally looks first for plain text data in the pasteboard and writes that to the standard output

Since plain text data is available as the image's URL, you'll always paste that, no matter what.

There is no way to tell pbpaste to get only a specified data type.

And just for completeness, here's the URL stored for an image, for example:

Screenshot taken with Pasteboard Inspector.

share|improve this answer

There is a utility just for your use case: pngpaste

You can install (a bit older) version using brew install pngpaste, or just git clone/make latest version.

share|improve this answer
This should be the accepted answer. – slipheed Jun 15 at 22:39

You could try opening image in a hex editor to access the raw file, I've used Hex Fiend on my mac and it does the job.

share|improve this answer
That requires you to save the image first. – slhck May 21 '12 at 15:06

You must log in to answer this question.

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