https://blog.greg.technology/2024/01/02/how-do-you-ocr-on-a-mac.html the greg technology blog [ ] how do you ocr on a mac using the cli or just python for free Jan 2, 2024 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" [step1] * 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" [step2] * 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: [step3] * 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 (...??) [step4] * 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 ) print(ocr_out) * THAT'S IT! x main site * github * e-mail * I was recently at the Recurse Center working on a lotta things. <<< Prev * The Recurse Webring * Next >>>