Mike Mike - 1 year ago 94
Bash Question

Can pbpaste access screen capture pasteboard on Mac OSX?

On Mac OSX, user does: cmd-option-shift-4 to capture screen to pasteboard (clipboard). Which pasteboard is this stored in? Can it be accessed by pbpaste?

command line tool pbpaste allows access of the pasteboard. I tried all the variations of this command and never generated output from the screen capture (but, if I paste into Preview, the screen capture is outputted).

pbpaste [-help] [-pboard {general | ruler | find | font}] [-Prefer {txt | rtf | ps}]

I tried each permutation of -pboard and -Prefer values with no luck.

Intended use would be a script like this:

bash script:

pbpaste > /tmp/tmp.png
tesseract /tmp/tmp.png /tmp/tmp -l eng #open source ocr tool
cat /tmp/tmp.txt #tool adds .txt


The answer I accepted is true, for the command pbpaste. But, I found what I am looking for. A command called pngpaste. I installed this via brew, in case anyone else ends up needing it.

So, my ocr from the png clipboard works like this now:


pngpaste /tmp/tmp.png

#open source ocr tool
tesseract /tmp/tmp.png /tmp/tmp -l eng

#tesseract adds .txt
cat /tmp/tmp.txt | pbcopy

Answer Source

No. pbpaste can only retrieve plain text, EPS, or RTF data from the pasteboard. A screenshot is none of those types, so pbpaste cannot access it.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download