TesseractOCR PHP, how do I catch the error if the image returns no text?
( ! ) Fatal error: Uncaught thiagoalessio\TesseractOCR\UnsuccessfulCommandException: Error!
TesseractOCR PHP, how do I catch the error if the image returns no text?
( ! ) Fatal error: Uncaught thiagoalessio\TesseractOCR\UnsuccessfulCommandException: Error!
This is what I came up with, it's all I need to catch the error:
<?php
require_once "vendor/autoload.php";
use thiagoalessio\TesseractOCR\TesseractOCR;
try{
$parse =
(new TesseractOCR('path-to-image/blank.gif'))
->executable('C:\Program Files\Tesseract-OCR\tesseract.exe')
->run();
echo $parse;
} catch(Exception $errors) {
echo 'Message: ' .$errors->getMessage();
}