, (*1)
Tesseract: a wrapper for the Tesseract OCR engine
A small PHP >=5.3 library that makes working with the open source Tesseract OCR engine
easier., (*2)
Installation
You need a working Tesseract installation. For more information about
installation and adding language support, see Tesseractâs README., (*3)
Then install this library, which is available on Packagist,
through Composer:, (*4)
$ composer require ddeboer/tesseract:1.0
Usage
If the tesseract binary is in your path, just do:, (*5)
use Ddeboer\Tesseract\Tesseract;
$tesseract = new Tesseract();
Otherwise, construct Tesseract with the path to the binary:, (*6)
$tesseract = new Tesseract('/usr/local/bin/tesseract');
Get version and supported languages information:, (*7)
$version = $tesseract->getVersion();
$languages = $tesseract->getSupportedLanguages();
Perform OCR on an image file:, (*8)
$text = $tesseract->recognize('myfile.tif');
Optionally, specify the language(s) as second argument:, (*9)
$text = $tesseract->recognize('myfile.tif', array('nld', 'eng'));
And specify Tesseractâs page seg mode as third argument:, (*10)
$text = $tesseract->recognize('myfile.tif', null, Tesseract::PAGE_SEG_MODE_AUTOMATIC_OSD);