bicycle/tesseract-bridge
PHP wrapper for Tesseract OCR with CLI and FFI backends. Configure the Tesseract binary, list available languages, and recognize text from images via a simple API. Tested on FreeBSD/Debian/Ubuntu with Tesseract 3/4.
A wrapper to work with Tesseract OCR inside PHP via CLI and/or FFI interfaces.
:bangbang: Tested only on FreeBSD, Debian and Ubuntu platforms with Tesseract OCR version 3 and 4 (see build logs).
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:
Please check our FAQ
tesseract-bridge is released under the MIT License.
How can I help you explore Laravel packages today?