OCR Image with Options Macro (v10.2)

[Requires Monterey]

This macro implements two of the approaches described in Optical Character Recognition (OCR) Script posted by Chris Stone.

But it adds all of the options available to tune accuracy in Apple's Vision framework. Mouse over the input fields for descriptions of their effects.

And if you're using Text Toolbox II, you can easily add this macro to that menu bar palette. We added a new macro named 77)OCR Image and used Execute a Macro to link this macro.

ss-661

The File option seems to work fine but I'm stumped why the Clipboard option just returns PNG for a PNG screenshot. The original code run from Script Debugger exhibits the same behavior so it's probably how I've been testing.

If it works for you, I'd appreciate knowing the trick.

The language options allow selection of a main language and multiple secondary languages. To select more than one secondary language, hold down the Command key.

OCR Image with Options.kmmacros (16 KB)

Keyboard Maestro Export

3 Likes

I use the native Apple Shortcut to OCR Images.

Download Macro(s): OCR Image (Text Recognition).kmmacros (3.7 KB)

Macro Image

Macro Notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.
System Information
  • macOS 13.3
  • Keyboard Maestro v10.2
1 Like

Thanks but the macro you've uploaded is incomplete without the Run OCR Shortcut.

But even running Shortcut's OCR macros (and I've tried several), I've never gotten it to work on my system. Hence my AppleScript embed on the Vision framework. Which does work and gives you finer control of the results by opening up Vision's options.

I can confirm that the OCR shortcut works great but it's nice to have options.

You can grab it here if you like. This particular version will OCR an image on the clipboard.

The Shortcut OCR Clipboard isn't included in your macro, @noisneil, but I do have one such two-action Shortcut in my collection. It does nothing but report the file name of the image on the System Clipboard on my unsupported hardware (much like the Clipboard option of my macro).

I've tried various ways to copy an image to the Clipboard (and the Clipboard History Switcher shows them as images) but none of these approaches reads the image data on my clipboard.

A problem, I emphasize, that's probably unique to me running Monterey on unsupported hardware. Although, if there's another way to get an image on the clipboard, I'm all ears.

Look again at the bit where it says THIS SHORTCUT. :wink:

The link was in my original post hyperlinked.

https://www.icloud.com/shortcuts/6bc7e9a484bd44aa9cdef47c712273ee

1 Like

Thanks, @noisneil and @jackk. I have that Shortcut (which I just downloaded again) but it doesn't work on my unsupported system for some reason. And it isn't just the Shortcut but the AppleScript in my macro that reads the Clipboard.

Does that Clipboard option in my macro work on your system? That would confirm the problem is mine alone.

I'm not at home rn. What OS are you on?

Monterey

Here's my method. It's quite a bit snappier than the script version, and hasn't returned a garbled result once.

OCR - Apple Version.kmmacros (28 KB)

Macro screenshot

Your method likely has great advantages for trickier image sources and alternate languages. :+1:t3:

Must be me (or my Shortcut app). That returns nothing on the clipboard here.

What I'd like to know is if my macro's Clipboard button works for anyone. It doesn't work here (unsupported hardware).

Yeah it works! Lovely HTML interface by the way.

Ah ha. Thanks, Neil. That confirms the issue with an image on the clipboard and it is there) is with my system and Shortcuts.

1 Like