Take a snapshot and recognize text
Switch branches/tags
Nothing to show
Clone or download
Latest commit f611b1a Dec 6, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE Initial commit Nov 9, 2018
OCR.alfredworkflow Fix stderr not redirected Nov 17, 2018
README.md Update README.md Dec 6, 2018
alfred-ocr.png Redirect stderr to stdout, and linearise process. Nov 9, 2018

README.md

Alfred Workflow OCR

Take a snapshot and recognize text

alfred-ocr.png

Installation

  1. Install tesseract on your system: sudo port install tesseract or brew install tesseract --with-all-languages
  2. Download the workflow
  3. Double click to install it in Alfred

Usage

Use the keywork OCR, take a screenshot, wait for the notification, paste the text. For better results, you can also add a language as optionnal argument like this: OCR fra (full list of language codes here).

Capture-d-e-cran-2018-11-09-a-10-06-07.png

What's inside?

Three lines of code:

export PATH=/usr/local/bin/:$PATH

screencapture -i /tmp/ocr_snapshot.png

tesseract /tmp/ocr_snapshot.png -l {query} stdout 2>&1

Discussion

On Alfred forum: https://www.alfredforum.com/topic/12006-ocr-extract-text-from-snapshot/

Known issues

Taking a snapshot from a different monitor than your main one with a different resolution will make the script buggy. You'll get a warning like this [ERROR: action.script] Warning. Invalid resolution 0 dpi. Using 70 instead. which leads to poor results of text recognition. A regex can hide the message: https://www.alfredforum.com/topic/12006-ocr-extract-text-from-snapshot/?tab=comments#comment-63118.

Credits

Inspired by the work of https://github.com/oott123/alfred-clipboard-ocr