PHPackages                             cdsmths/laravel-ocr-space - 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. cdsmths/laravel-ocr-space

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

cdsmths/laravel-ocr-space
=========================

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

1.0.6(1y ago)12321.6k↓59.9%11[2 PRs](https://github.com/cdsmths/laravel-ocr-space/pulls)MITPHPPHP ^8.2CI passing

Since Jan 12Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/cdsmths/laravel-ocr-space)[ Packagist](https://packagist.org/packages/cdsmths/laravel-ocr-space)[ Docs](https://github.com/cdsmths/laravel-ocr-space)[ GitHub Sponsors](https://github.com/cdsmths)[ RSS](/packages/cdsmths-laravel-ocr-space/feed)WikiDiscussions main Synced yesterday

READMEChangelog (10)Dependencies (12)Versions (13)Used By (0)

[![Latest Version on Packagist](https://camo.githubusercontent.com/9f11621f2020cfbb1c89a42ceae1d12843fddca963345e54e88575af5366ca43/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6364736d7468732f6c61726176656c2d6f63722d73706163652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cdsmths/laravel-ocr-space)[![GitHub Tests Action Status](https://camo.githubusercontent.com/d700a40ee5921b843370af366d58e631e9dd2fa2793c1698c99b3d13a37a00f3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6364736d7468732f6c61726176656c2d6f63722d73706163652f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/cdsmths/laravel-ocr-space/actions/workflows/tests.yml)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/fe00babad4bfd7e14ff5a76ab73ea0ee907ee34c9287e1325d9a9d4f44d971d1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6364736d7468732f6c61726176656c2d6f63722d73706163652f666f726d6174732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/cdsmths/laravel-ocr-space/actions?query=workflow%3A%22formats%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/a123fa4ffb84fa6c24acf88422bf8bc12305bf5e435a29cb2b56612961a7c1e1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6364736d7468732f6c61726176656c2d6f63722d73706163652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cdsmths/laravel-ocr-space)

[![laravel-ocr-space-social-card](https://private-user-images.githubusercontent.com/224501/402342008-4333e2bc-1f5c-401f-9646-76bb57314057.jpg?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3ODI5NjM5MTIsIm5iZiI6MTc4Mjk2MzYxMiwicGF0aCI6Ii8yMjQ1MDEvNDAyMzQyMDA4LTQzMzNlMmJjLTFmNWMtNDAxZi05NjQ2LTc2YmI1NzMxNDA1Ny5qcGc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwNzAyJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDcwMlQwMzQwMTJaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1hMDA5NmI1ZGJjOTJlZmJmYzlkNDY2MTYzNjY0Y2NmOWNkMDJkNDE0MDQwMGMyNjE4ZTA0Y2RmOTc3NjM4MDE3JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZyZXNwb25zZS1jb250ZW50LXR5cGU9aW1hZ2UlMkZqcGVnIn0.lg9dRyRnHuosvcboJPUhTfrwAHy77rVj7R4YC-kUBtU)](https://private-user-images.githubusercontent.com/224501/402342008-4333e2bc-1f5c-401f-9646-76bb57314057.jpg?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3ODI5NjM5MTIsIm5iZiI6MTc4Mjk2MzYxMiwicGF0aCI6Ii8yMjQ1MDEvNDAyMzQyMDA4LTQzMzNlMmJjLTFmNWMtNDAxZi05NjQ2LTc2YmI1NzMxNDA1Ny5qcGc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwNzAyJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDcwMlQwMzQwMTJaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1hMDA5NmI1ZGJjOTJlZmJmYzlkNDY2MTYzNjY0Y2NmOWNkMDJkNDE0MDQwMGMyNjE4ZTA0Y2RmOTc3NjM4MDE3JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZyZXNwb25zZS1jb250ZW50LXR5cGU9aW1hZ2UlMkZqcGVnIn0.lg9dRyRnHuosvcboJPUhTfrwAHy77rVj7R4YC-kUBtU)

Laravel OCR Space
=================

[](#laravel-ocr-space)

Laravel OCR Space is a package that allows you to use the [OCR.Space](https://ocr.space/ocrapi) API in your Laravel application for Optical Character Recognition (OCR).

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

[](#installation)

You can install the package via composer:

```
composer require cdsmths/laravel-ocr-space
```

You can publish the config file with:

```
php artisan vendor:publish --provider="Codesmiths\LaravelOcrSpace\LaravelOcrSpaceServiceProvider" --tag="laravel-ocr-space"
```

Usage
-----

[](#usage)

### Get a free Ocr.Space api key

[](#get-a-free-ocrspace-api-key)

You can get a free api key from [ocr.space](https://ocr.space/ocrapi/freekey). This key is required to use the package.

You should add this key to your `.env`:

```
OCR_SPACE_API_KEY="YOUR API KEY"

```

### Parsing an Image file

[](#parsing-an-image-file)

```
use Codesmiths\LaravelOcrSpace\OcrSpaceOptions;
use Codesmiths\LaravelOcrSpace\Facades\OcrSpace;

$filePath = 'path/to/image.jpg';

$result = OcrSpace::parseImageFile(
    $filePath,
    OcrSpaceOptions::make(),
);

dd($result);
```

### Parsing an Image URL

[](#parsing-an-image-url)

```
use Codesmiths\LaravelOcrSpace\OcrSpaceOptions;
use Codesmiths\LaravelOcrSpace\Facades\OcrSpace;

$imageUrl = 'https://example.com/image.jpg';

$options = new \Codesmiths\LaravelOcrSpace\OcrSpaceOptions();

$result = OcrSpace::parseImageUrl(
    $imageUrl,
    OcrSpaceOptions::make(),
);

dd($result);
```

### Parsing an base64 encoded image

[](#parsing-an-base64-encoded-image)

```
use Codesmiths\LaravelOcrSpace\OcrSpaceOptions;
use Codesmiths\LaravelOcrSpace\Facades\OcrSpace;

$base64Image = 'base64 encoded image';

$result = OcrSpace::parseBase64Image(
    $base64Image,
    OcrSpaceOptions::make(),
);

dd($result);
```

### Parsing an binary image

[](#parsing-an-binary-image)

```
use Codesmiths\LaravelOcrSpace\OcrSpaceOptions;
use Codesmiths\LaravelOcrSpace\Facades\OcrSpace;

$binaryImage = file_get_contents('path/to/image.jpg');

// File type is required for binary images
$options = OcrSpaceOptions::make()
    ->fileType('image/jpg');

$result = OcrSpace::parseBinaryImage(
    $binaryImage,
    $options,
);

dd($result);
```

### Parsing with parseImage method

[](#parsing-with-parseimage-method)

```
use Codesmiths\LaravelOcrSpace\OcrSpaceOptions;
use Codesmiths\LaravelOcrSpace\Facades\OcrSpace;
use Codesmiths\LaravelOcrSpace\Enums\InputType;

$filePath = 'path/to/image.jpg';

$result = OcrSpace::parseImage(
    InputType::File
    $filePath,
    OcrSpaceOptions::make(),
);

dd($result);
```

### Options

[](#options)

You can pass options to the `parseImageFile`, `parseImageUrl`, `parseBase64Image`, `parseBinaryImage` and `parseImage` methods.

```
use Codesmiths\LaravelOcrSpace\OcrSpaceOptions;
use Codesmiths\LaravelOcrSpace\Enums\Language;
use Codesmiths\LaravelOcrSpace\Enums\OcrSpaceEngine;

// All possible options
$options = OcrSpaceOptions::make()
        ->language(Language::English)
        ->overlayRequired(true)
        ->fileType('image/png')
        ->detectOrientation(true)
        ->isCreateSearchablePdf(true)
        ->isSearchablePdfHideTextLayer(true)
        ->scale(true)
        ->isTable(true)
        ->OCREngine(OcrSpaceEngine::Engine1); // Engine1, Engine2, or Engine3
```

#### OCR Engines

[](#ocr-engines)

OCR.Space provides three different OCR engines:

- **Engine1**: The original OCR engine, best for standard documents
- **Engine2**: Improved OCR engine with better accuracy for most use cases
- **Engine3**: The latest engine with significantly superior text recognition capabilities

You can specify which engine to use:

```
use Codesmiths\LaravelOcrSpace\Enums\OcrSpaceEngine;

// Use Engine 1
$options = OcrSpaceOptions::make()->ocrEngine(OcrSpaceEngine::Engine1);

// Use Engine 2
$options = OcrSpaceOptions::make()->ocrEngine(OcrSpaceEngine::Engine2);

// Use Engine 3 (recommended for best accuracy)
$options = OcrSpaceOptions::make()->ocrEngine(OcrSpaceEngine::Engine3);
```

### Response

[](#response)

All methods return an instance of `Codesmiths\LaravelOcrSpace\OcrSpaceResponse` which has the following methods:

```
$response->getParsedResults(); // Returns an Collection `ParsedResult`
$response->getOCRExitCode(); // Returns the exit code
$response->getIsErroredOnProcessing(); // Returns a boolean
$response->getErrorMessage(); // Returns the error message
$response->getErrorMessageDetails(); // Returns the error message details
$response->getProcessingTimeInMilliseconds(); // Returns the processing time in milliseconds
$response->getSearchablePdfUrl(); // Returns the searchable pdf url
$response->hasSearchablePdfUrl(); // Returns if the response has a searchable pdf url
$response->hasError(); // Returns if the response has an error
$response->hasParsedResults(); // Returns if the response has parsed results
```

### Parsed Results

[](#parsed-results)

If you want to get value from `getParsedResults()`, you can use the following methods:

```
$parsedResults = $response->getParsedResults();

$parsedResults->first()->getParsedText(), // Returns the parsed text from the first parsed result
$parsedResults->first()->getTextOverlay(), // Returns the text overlay from the first parsed result
$parsedResults->first()->getFileParseExitCode(), // Returns the file parse exit code from the first parsed result
$parsedResults->first()->getErrorMessage(), // Returns the error message from the first parsed result
$parsedResults->first()->getErrorDetails(), // Returns the error message details from the first parsed result
$parsedResults->first()->getSerializedParsedText(), // Returns the serialized parsed text from the first parsed result
```

License / Credits
=================

[](#license--credits)

This package our Codesmiths is not affiliated with [OCR.Space](https://ocr.space/ocrapi) and is not an official package. It is a wrapper around the OCR.Space API.

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

48

—

FairBetter than 93% of packages

Maintenance59

Moderate activity, may be stable

Popularity44

Moderate usage in the ecosystem

Community19

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 75.4% 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 ~3 days

Total

8

Last Release

516d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/224501?v=4)[Thomas van der Westen](/maintainers/tdwesten)[@tdwesten](https://github.com/tdwesten)

---

Top Contributors

[![tdwesten](https://avatars.githubusercontent.com/u/224501?v=4)](https://github.com/tdwesten "tdwesten (52 commits)")[![Copilot](https://avatars.githubusercontent.com/in/1143301?v=4)](https://github.com/Copilot "Copilot (4 commits)")[![tanogalego](https://avatars.githubusercontent.com/u/8809003?v=4)](https://github.com/tanogalego "tanogalego (3 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")[![RVxLab](https://avatars.githubusercontent.com/u/46111684?v=4)](https://github.com/RVxLab "RVxLab (2 commits)")[![ZhafranBahij](https://avatars.githubusercontent.com/u/72001795?v=4)](https://github.com/ZhafranBahij "ZhafranBahij (2 commits)")[![muhammadZihad](https://avatars.githubusercontent.com/u/48516246?v=4)](https://github.com/muhammadZihad "muhammadZihad (1 commits)")[![therooster-pixels](https://avatars.githubusercontent.com/u/92294822?v=4)](https://github.com/therooster-pixels "therooster-pixels (1 commits)")[![ziming](https://avatars.githubusercontent.com/u/679513?v=4)](https://github.com/ziming "ziming (1 commits)")

---

Tags

laravelOCRlaravel-ocr-spaceocr.spaceCodesmithsThomas van der Westen

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/cdsmths-laravel-ocr-space/health.svg)

```
[![Health](https://phpackages.com/badges/cdsmths-laravel-ocr-space/health.svg)](https://phpackages.com/packages/cdsmths-laravel-ocr-space)
```

###  Alternatives

[stephenjude/filament-blog

Filament Blog Builder

20619.4k](/packages/stephenjude-filament-blog)

PHPackages © 2026

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