Laravel Packages

Laravel SpaceOCR: Parse Images and Multi-page PDFs in Laravel

Published
Laravel SpaceOCR: Parse Images and Multi-page PDFs in Laravel image

The Laravel OCR Space package integrates with the OCRSpace API to provide a simple way to parse images and multi-page documents into JSON using Optical Character Recognition. Once you configure this package, you can use the provided OcrSpace service to interact with the API:

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

OcrSpace::parseImageFile(
    'path/to/image.jpg'
    OcrSpaceOptions::make(),
);

OcrSapce::parseImageUrl(
    $imageUrl,
    OcrSpaceOptions::make(),
);

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

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

Using the API, you might get something like the following example back from the OCRSpace API in JSON format:

{
    "ParsedResults":
    [
        {
            "TextOverlay":
            {
                "Lines":
                [],
                "HasOverlay": false,
                "Message": "Text overlay is not provided as it is not requested"
            },
            "TextOrientation": "0",
            "FileParseExitCode": 1,
            "ParsedText": "ELLIOT\r\n29 Comments f Facebook Twitter G* Google O Pinterest in LinkedIn 6 Reddit\r\nLockheed's I-J-2S spy planes are famously difficult to launch and land....",
            "ErrorMessage": "",
            "ErrorDetails": ""
        }
    ]
}

You can learn more about this package, get full installation instructions, and view the source code on GitHub. This package requires an ORCSpace API account, which you can learn more about from the documentation. They have a free tier and various paid accounts with more features, such as larger file sizes, PDF page limits, and an SLA of 100% uptime.

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Sponsored

laravelcloud logo
Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Visit Laravel Cloud

The latest

View all →
Slow Job Alerts and Replica Commit IDs in Laravel 13.40 image

Slow Job Alerts and Replica Commit IDs in Laravel 13.40

Read article
Flock: A Free, Native Herd Alternative for Laravel image

Flock: A Free, Native Herd Alternative for Laravel

Read article
Live Props for Real-Time Updates in Inertia.js v3.11 image

Live Props for Real-Time Updates in Inertia.js v3.11

Read article
Cooldown Dependency Policy now in Composer 2.11 image

Cooldown Dependency Policy now in Composer 2.11

Read article
Email Sending and Testing for Laravel in One Account image

Email Sending and Testing for Laravel in One Account

Read article
Decide with Jev: Tie Every AI Check to the Exact Draft image

Decide with Jev: Tie Every AI Check to the Exact Draft

Read article