Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ddeboer/tesseract

A PHP wrapper for the Tesseract OCR engine
https://github.com/ddeboer/tesseract

ocr php tesseract

Last synced: 3 months ago
JSON representation

A PHP wrapper for the Tesseract OCR engine

Awesome Lists containing this project

README

        

[![Build Status](https://travis-ci.org/ddeboer/tesseract.png?branch=master)](https://travis-ci.org/ddeboer/tesseract)

Tesseract: a wrapper for the Tesseract OCR engine
================================================

A small PHP >=5.3 library that makes working with the open source [Tesseract OCR engine](https://github.com/tesseract-ocr)
easier.

Installation
------------

You need a working Tesseract installation. For more information about
installation and adding language support, see Tesseract’s [README](https://github.com/tesseract-ocr/tesseract/blob/master/README.md).

Then install this library, which is available on [Packagist](http://packagist.org/packages/ddeboer/tesseract),
through [Composer](http://getcomposer.org/):

$ composer require ddeboer/tesseract:1.0

Usage
-----

If the `tesseract` binary is in your path, just do:

```php
use Ddeboer\Tesseract\Tesseract;

$tesseract = new Tesseract();
```

Otherwise, construct Tesseract with the path to the binary:

```php
$tesseract = new Tesseract('/usr/local/bin/tesseract');
```

Get version and supported languages information:

```php
$version = $tesseract->getVersion();

$languages = $tesseract->getSupportedLanguages();
```

Perform OCR on an image file:

```php
$text = $tesseract->recognize('myfile.tif');
```

Optionally, specify the language(s) as second argument:

```php
$text = $tesseract->recognize('myfile.tif', array('nld', 'eng'));
```

And specify Tesseract’s page seg mode as third argument:

```php
$text = $tesseract->recognize('myfile.tif', null, Tesseract::PAGE_SEG_MODE_AUTOMATIC_OSD);
```