It’s easy enough to read an image and pull the text yourself. But dynamically pulling text from a photo is a bit tougher, and thankfully, imgclip offers a fairly simple solution.
This command-line tool runs in the terminal for Mac, Windows, and Linux. It simply takes an argument for the image file along with the language, then returns the text copied to your clipboard.
Read Also: Why All Developers Should Learn Command Line
You can install the whole library via npm and it’s a pretty simple install. The thing is only a few KB large and it comes with a JS file that you can browse on GitHub.
Imgclip uses the Tesseract.js library for automating image processing and pulling text via OCR. It’s one of the most powerful OCR libraries to date, and it’s completely open source just like imgclip.
I think I’m most impressed with the quality and speed of this tool. It really does work to pull accurate text and it’s one of the simplest tools to use.
The imgclip command should be run directly in the terminal, followed by the relative path to the image. You can also add four options onto the end to customize the output.
--help: outputs usage information
--version: outputs the version number
--lang: outputs the language of the text in the image
As of this writing, Tesseract supports 65 languages with more on the way. The code you append to the
--lang tag should be whatever code is used in those Tesseract files.
-l eng will search the image for English text, while
-l jpn will search for Japanese text and you can even run
-l jpn_vert to search for vertically-oriented Japanese text.
Since imgclip relies heavily on Tesseract, you basically have the power of that entire library at your disposal.
To get started, visit the GitHub page and download a copy locally, or install it to a specific directory via npm. Then, you can run the tool in the terminal like an application to parse any image you want.
To see imgclip in action, check out this brief video created as an imgclip demo.
The post How to Extract Text from Images Using Command Line appeared first on Hongkiat.WordPress Website Development