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.