1. Go to this page and download the library: Download cdsmths/laravel-ocr-space library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cdsmths / laravel-ocr-space example snippets
use Codesmiths\LaravelOcrSpace\OcrSpaceOptions;
use Codesmiths\LaravelOcrSpace\Facades\OcrSpace;
$filePath = 'path/to/image.jpg';
$result = OcrSpace::parseImageFile(
$filePath,
OcrSpaceOptions::make(),
);
dd($result);
use Codesmiths\LaravelOcrSpace\OcrSpaceOptions;
use Codesmiths\LaravelOcrSpace\Facades\OcrSpace;
$imageUrl = 'https://example.com/image.jpg';
$options = new \Codesmiths\LaravelOcrSpace\OcrSpaceOptions();
$result = OcrSapce::parseImageUrl(
$imageUrl,
OcrSpaceOptions::make(),
);
dd($result);
use Codesmiths\LaravelOcrSpace\OcrSpaceOptions;
use Codesmiths\LaravelOcrSpace\Facades\OcrSpace;
$base64Image = 'base64 encoded image';
$result = OcrSpace::parseBase64Image(
$base64Image,
OcrSpaceOptions::make(),
);
dd($result);
use Codesmiths\LaravelOcrSpace\OcrSpaceOptions;
use Codesmiths\LaravelOcrSpace\Facades\OcrSpace;
$binaryImage = file_get_contents('path/to/image.jpg');
// File type is
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);
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);
$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
$repsonse->hasParsedResults(); // Returns if the response has parsed results