Getting text from Image using PHP

Have you ever considered using PHP to read text from images. Indeed you can. There's a probability that one of your web applications will require you to interpret text from an image. Therefore, in today's article, we'll show you how to use PHP to read text from a picture.

INSTRUCTION

Tesseract Open Source OCR Engine, which enables for text recognition from images, will be used. Tesseract OCR can be installed on any OS, including Linux, Windows, and Mac. Visit their wiki page for more information.

The first step is complete once Tesseract OCR has been installed on your server. Ensure that you have added the environment variable for Windows users (For eg. C:Program FilesTesseract-OCR).

The Tesseract OCR library needs to be installed in your PHP app next. To add the library to your project, run the command listed below.

composer require thiagoalessio/tesseract_ocr

We have attached an image below to get its text.

The PHP code needed to read the image will then be written below.

require_once "vendor/autoload.php";
use thiagoalessio\TesseractOCR\TesseractOCR;
echo (new TesseractOCR('text-image.png'))->run();

The final result output you should get text as follows:

Welcome to learnweb.top!Nice to see you here.

All done! hope it's helpful. Have a nice day.

Similar Tutorials

Comments