Added one more repsonse for empty invalid image
This commit is contained in:
@@ -52,6 +52,13 @@ use thiagoalessio\TesseractOCR\TesseractOCR;
|
||||
->config('tessedit_char_whitelist', '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz')
|
||||
->run();
|
||||
|
||||
$text = trim($text); // remove whitespace
|
||||
|
||||
if (empty($text)) {
|
||||
// No text found
|
||||
return response()->json(['success' => true, 'text' => 'Text not found']);
|
||||
}
|
||||
|
||||
//return response()->json(['success' => true, 'text' => $text]);
|
||||
$lines = preg_split('/\r\n|\r|\n/', $text);
|
||||
$serials = array_filter(array_map('trim', $lines), fn($line) => preg_match('/^[A-Za-z0-9]+$/', $line));
|
||||
|
||||
Reference in New Issue
Block a user