Thursday, February 29, 2024
Google search engine
HomeUncategorizedShow HN: How do you OCR on a Mac using the CLI...

Show HN: How do you OCR on a Mac using the CLI or just Python for free

a kind reader reached out about all of my iphone alarms and asked how specifically did I run OCR on my mac. I’m not one to gatekeep, so here’s how you can get yourself a nice local ocr ‘service’ that works in the terminal/CLI/python and costs 0 dollars:

  • ((by the way sharing Shortcuts is really weird which is why I’m having you do this all manually…))
  • (also, most of the stuff below only needs to be done once – after that, actually ocr’ing is easy)
  • open the Shortcuts app in your Applications folder
  • click the “+” button to create a new shortcut
  • in the right sidebar, search for “extract text

  • you should see “Extract Text from Image” in the list of possible actions. drag it from the right sidebar into the main area on the left
  • in the “Extract text from …” action that’s now on the left, click on the pale “Image” blue-ish pill
  • pick “Shortcut Input

  • you’ll see a big “Receive Any input from Nowhere” action appear above the “Extract text from Shortcut Input”. it’s all good, leave it as is
  • in the right sidebar, search for “copy”. you should see “Copy to Clipboard”. drag that action below the “Extract text from …” one
    • dragging the “Copy to …” action below the “Extract from …” is really annoyingly hard. just keep dragging it really below and it will work at some point
  • your final setup should look like this:

  • in the last action, make sure that after “Copy” it does say “Text from Image”!
  • you’re like almost done!!
  • in the window title bar, type stuff to name the shortcut. because I’m from a generation, I recommend naming it “extract-text” or “ocr-text” or something simple with no spaces and all lowercase. sorry. press enter after naming the shortcut otherwise it won’t remember the name (…??)

  • ok you may be actually done here I think
  • try out the shortcut in your terminal:
shortcuts run ocr-text -i 
  • then try command-V – do you see the resulting text? if yes, you’re good to go!!!
  • from python, you can do the following:
import subprocess

file_path = '... some file path ...'
ocr_out = subprocess.check_output(
    f'shortcuts run ocr-text -i "{file_path}"', shell=True
  • THAT’S IT! x

Read More



  1. Just wish to say your article is as surprising The clearness in your post is just cool and i could assume youre an expert on this subject Fine with your permission allow me to grab your RSS feed to keep updated with forthcoming post Thanks a million and please keep up the enjoyable work

  2. I engaged on this casino platform and won a considerable sum of money, but after some time, my mother fell sick, and I needed to withdraw some money from my account. Unfortunately, I faced difficulties and couldn’t finalize the cashout. Tragically, my mom died due to this casino site. I request for your support in bringing attention to this website. Please support me in seeking justice, so that others won’t undergo the pain I am going through today, and stop them from crying tears like mine. 😭😭😭�


Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments