PHPackages                             ahmedghanem00/tesseract-ocr - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. ahmedghanem00/tesseract-ocr

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ahmedghanem00/tesseract-ocr
===========================

A PHP wrapper for Tesseract-OCR binary

1.0.11(1y ago)058MITPHPPHP ^8.2

Since Jun 1Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ahmedghanem00/tesseract-ocr)[ Packagist](https://packagist.org/packages/ahmedghanem00/tesseract-ocr)[ RSS](/packages/ahmedghanem00-tesseract-ocr/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (8)Versions (5)Used By (0)

Tesseract-OCR PHP Wrapper
=========================

[](#tesseract-ocr-php-wrapper)

A PHP wrapper for Tesseract-OCR binary.

Originally inspired from [ddeboer/tesseract](https://github.com/ddeboer/tesseract) with added features + some Improvements.

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

[](#installation)

```
$ composer require ahmedghanem00/tesseract-ocr

```

Usage
=====

[](#usage)

if the tesseract is added to your path, You can just do:

```
$tesseract = new \ahmedghanem00\TesseractOCR\Tesseract();
```

Otherwise, You can do:

```
$tesseract = new \ahmedghanem00\TesseractOCR\Tesseract("path/to/binary/location");
# OR, If you already have an initiated instance
$tesseract->setBinaryPath("path/to/binary/location");
```

To specify the tesseract process timeout:

```
$tesseract = new \ahmedghanem00\TesseractOCR\Tesseract(processTimeout: 3);
# OR
$tesseract->setProcessTimeout(2.5);
```

To specify a custom tessdata-dir:

```
$tesseract->setTessDataDirPath("path/to/data/dir")
```

To reset tessdata-dir to default:

```
$tesseract->resetTessDataDirPath();
```

To get version of the binary:

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

To get all the supported languages:

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

To OCR an Image:

```
$result = $tesseract->recognize("test.png");
## OR
$result = $tesseract->recognize("https://example.com/test.png");
## etc.
```

Thanks to the [Intervention/image](https://github.com/Intervention/image) package. The recognize method can accept different sources for an image:

```
- Path of the image in filesystem.
- URL of an image (allow_url_fopen must be enabled).
- Binary image data.
- Data-URL encoded image data.
- Base64 encoded image data.
- PHP resource of type gd
- Imagick instance
- Intervention\Image\Image instance
- SplFileInfo instance (To handle Laravel file uploads via Symfony\Component\HttpFoundation\File\UploadedFile)

```

To Specify the language(s):

```
$result = $tesseract->recognize("test.png", langs: ["eng", "ara"]);
```

To specify the Page-Segmentation-Model (PSM):

```
use ahmedghanem00\TesseractOCR\Enum\PSM;

# using PSM enum
$result = $tesseract->recognize("test.png", psm: PSM::SINGLE_BLOCK);
# OR by using id directly
$result = $tesseract->recognize("test.png", psm: 3);
```

To specify the OCR-Engine-Mode (OEM):

```
use ahmedghanem00\TesseractOCR\Enum\OEM;

# using OEM enum
$result = $tesseract->recognize("test.png", oem: OEM::LEGACY_WITH_LSTM);
# OR by using id directly
$result = $tesseract->recognize("test.png", oem: 3);
```

To specify the DPI of the input image:

```
$result = $tesseract->recognize("test.png", dpi: 200);
```

To make the recognize method output the result as a searchable PDF instead of raw text:

```
$pdfBinaryData = $tesseract->recognize("test.png", outputAsPDF: true);

file_put_contents("result.pdf", $pdfBinaryData)
```

To specify words-file or patterns-file:

```
$result = $tesseract->recognize("test.png", wordsFilePath: "/path/to/file");
# OR
$result = $tesseract->recognize("test.png", patternsFilePath: "/path/to/file");
```

To set a config parameters:

```
use ahmedghanem00\TesseractOCR\ConfigBag;

$config = ConfigBag::new()
    ->setParameter("tessedit_char_whitelist", "abcrety")
    ->setParameter("textord_pitch_range", 3);

$result = $tesseract->recognize("test.png", config: $config);
```

You can also run `tesseract --print-parameters` to see the list of available config parameters.

Licence
=======

[](#licence)

Package is licensed under the [MIT License](http://opensource.org/licenses/MIT). For more info, You can take a look at the [License File](LICENSE).

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~185 days

Total

3

Last Release

705d ago

PHP version history (2 changes)1.0.0PHP &gt;=8.1

1.0.10PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/41ca670c714d793e5dd90b8473db6af39b137d3c863883b081c0ea4426d8d671?d=identicon)[ahmedghanem00](/maintainers/ahmedghanem00)

---

Top Contributors

[![ahmedghanem00](https://avatars.githubusercontent.com/u/124502255?v=4)](https://github.com/ahmedghanem00 "ahmedghanem00 (41 commits)")

---

Tags

image-to-textocrocr-recognitionphpphp-wrappertesseracttext-recognitionOCRTesseracttext recognitionphp-wrapperocr recognition

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ahmedghanem00-tesseract-ocr/health.svg)

```
[![Health](https://phpackages.com/badges/ahmedghanem00-tesseract-ocr/health.svg)](https://phpackages.com/packages/ahmedghanem00-tesseract-ocr)
```

###  Alternatives

[thiagoalessio/tesseract_ocr

A wrapper to work with Tesseract OCR inside PHP.

3.0k3.3M25](/packages/thiagoalessio-tesseract-ocr)[shlinkio/shlink

A self-hosted and PHP-based URL shortener application with CLI and REST interfaces

4.8k4.3k](/packages/shlinkio-shlink)[ddeboer/tesseract

A wrapper for the Tesseract OCR engine

23135.1k](/packages/ddeboer-tesseract)[cdsmths/laravel-ocr-space

OCR PDF's and images with the OCR.Space API from Laravel

11915.8k](/packages/cdsmths-laravel-ocr-space)[andersonls/zpl

 This library is a php wrapper for the ZPL Programming Language.

34127.1k](/packages/andersonls-zpl)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
