A wrapper to work with Tesseract OCR inside PHP via CLI and/or FFI interfaces.
Via Composer:
$ composer require bicycle/tesseract-bridge
-
CLI ```php use Bicycle\Tesseract\Bridge as TesseractBridge;
$configuration = TesseractBridge\Configuration(['binary_path' => 'tesseract']); $bridge = new TesseractBridge\CLI($configuration); echo $bridge->testGetVersion(); print_r($bridge->getAvailableLanguages()); echo $bridge->recognizeFromFile('eurotext.png'); // Set proper path here ```
-
FFI ```php use Bicycle\Tesseract\Bridge as TesseractBridge;
$configuration = TesseractBridge\Configuration(['binary_path' => 'tesseract']); $bridge = new TesseractBridge\FFI($configuration); echo $bridge->testGetVersion(); print_r($bridge->getAvailableLanguages()); echo $bridge->recognizeFromFile('eurotext.png'); // Set proper path here ```
-
CLI ```php use Bicycle\Tesseract\Bridge as TesseractBridge;
$configuration = TesseractBridge\Configuration(['binary_path' => 'tesseract']); $bridge = new TesseractBridge\CLI($configuration); echo $bridge->testGetVersion(); print_r($bridge->getAvailableLanguages()); echo $bridge->recognizeFromFile('eurotext.png', ['deu']); // Set proper path here ```
-
FFI ```php use Bicycle\Tesseract\Bridge as TesseractBridge;
$configuration = TesseractBridge\Configuration(['binary_path' => 'tesseract']); $bridge = new TesseractBridge\FFI($configuration); echo $bridge->testGetVersion(); print_r($bridge->getAvailableLanguages()); echo $bridge->recognizeFromFile('eurotext.png', ['deu']); // Set proper path here ```
You can contribute to this project by:
- Opening an Issue if you found a bug or wish to propose a new feature;
- Opening PR if you want to improve/create/fix something
Please check our FAQ
tesseract-bridge is released under the MIT License.