From a983d116cf346798c2206878890c235732cb73c7 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Thu, 23 Oct 2025 15:57:28 +0530 Subject: [PATCH] Added one more repsonse for empty invalid image --- routes/web.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/routes/web.php b/routes/web.php index c296db3..52489c0 100644 --- a/routes/web.php +++ b/routes/web.php @@ -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));