Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

2 Answers 2

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

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.

http://ridiculousfish.com/hexfiend/

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.