Mike Mike - 4 months ago 16
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:

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


EDIT:

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:

#!/bin/bash

#https://github.com/jcsalterego/pngpaste
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

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.