[英]macOS: How to access the Live Text OCR functionality from AppleScript/JXA?
As of macOS Monterey it is possible to select text in images in Preview.从 macOS Monterey 开始,可以在预览中选择图像中的文本。
Is this OCR functionality available from AppleScript and/or JXA (JavaScript for Automation)? AppleScript 和/或 JXA(用于自动化的 JavaScript)是否提供此 OCR 功能?
In Script Editor.app
File > Open dictionary... I selected the Preview.app and looked at the API for Standard Suite and Text Suite but there doesn't seem to be anything related to OCR.在Script Editor.app
File > Open dictionary...我选择了Preview.app并查看了Standard Suite和Text Suite的 API,但似乎没有任何与 OCR 相关的内容。 (The Text Suite apparently has to do with drawing text on picture and not text extraction.) (文本套件显然与在图片上绘制文本而不是文本提取有关。)
I have also searched for text recognition actions in Automator.app but didn't see anything suitable.我还在 Automator.app 中搜索了文本识别操作,但没有看到任何合适的内容。
There isn't (yet?) a way to directly access OCR from AppleScript, but the workaround that I'm using is to use OwlOCR .没有(还没有?)从 AppleScript 直接访问 OCR 的方法,但我正在使用的解决方法是使用OwlOCR 。 This is an app that can capture text from the screen and output it to PDF, or plant text to the clipboard.这是一款可以从屏幕上捕获文本并将其输出为 PDF 或将文本植入剪贴板的应用程序。 Crucially for our purposes, it can also be controlled from the command line , and you can wrap those shell commands in an AppleScript “do shell script” command.对我们来说至关重要的是,它还可以 从命令行进行控制,您可以将这些 shell 命令包装在 AppleScript “do shell script”命令中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.