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

serpapi logo
SerpApi

The Web Search API for Your LLM and AI Applications

Visit SerpApi

The latest

View all →
Laravel AI SDK 1.4 Lets Agents Recover From Tool Failures image

Laravel AI SDK 1.4 Lets Agents Recover From Tool Failures

Read article
Laravel Read Replicas: Check if a Replica Has Caught Up image

Laravel Read Replicas: Check if a Replica Has Caught Up

Read article
UUID Request Input and Migration Failure Events in Laravel 13.42 image

UUID Request Input and Migration Failure Events in Laravel 13.42

Read article
Replay Missed Laravel Scheduled Tasks With Schedule Catchup image

Replay Missed Laravel Scheduled Tasks With Schedule Catchup

Read article
Search Polymorphic Relations and Filament Tables With Laravel Searchable image

Search Polymorphic Relations and Filament Tables With Laravel Searchable

Read article
Laravel Rest Api 3.0: Typed Fields, Metrics, and OpenAPI Docs image

Laravel Rest Api 3.0: Typed Fields, Metrics, and OpenAPI Docs

Read article