** A slightly modified version from nicooprat's project **
Read the Full tutorial here.
You can also add a language as optionnal argument like this: ocr fra
(full list of language codes here).
For changing the default languages, please read my Medium article.
-
Install
tesseract
on your system:a. Install Homebrew if you haven't
b. Then
brew install tesseract
(if you need English only) orbrew install tesseract-lang
( if you need additional langugages, this will install most of the popular languages) -
Download the workflow
-
Double click to install it in Alfred
export PATH=/usr/local/bin/:$PATH
screencapture -i /tmp/ocr_snapshot.png
if [{query} = ""]; then
# now using OCR for traditional Chinese and English
# replace (chi_tra+eng) with your default language(s)
tesseract /tmp/ocr_snapshot.png stdout -l chi_tra+eng 2>&1
else
tesseract /tmp/ocr_snapshot.png stdout -l {query} 2>&1
fi
**(choose your language codes from here!).
On Alfred forum: https://www.alfredforum.com/topic/12006-ocr-extract-text-from-snapshot/
Based on project by nicooprat