krishnachoudhary-hclguvi commited on
Commit
f4a6b1e
·
unverified ·
1 Parent(s): 8a5e5fe

Fix EasyOCR crash before metadata generation

Browse files
Files changed (1) hide show
  1. extractors/ocr_extractor.py +7 -0
extractors/ocr_extractor.py CHANGED
@@ -136,6 +136,13 @@ def _reconstruct_from_boxes(results: list) -> str:
136
  def extract_image(file_path: str) -> ExtractionResult:
137
  """Extract text from an image using the best available OCR engine."""
138
  start_time = time.time()
 
 
 
 
 
 
 
139
 
140
  # 1. Check for EasyOCR (Preferred)
141
  if EASYOCR_AVAILABLE:
 
136
  def extract_image(file_path: str) -> ExtractionResult:
137
  """Extract text from an image using the best available OCR engine."""
138
  start_time = time.time()
139
+ original_size = (0, 0)
140
+ try:
141
+ with Image.open(file_path) as img:
142
+ original_size = img.size
143
+ except Exception:
144
+ # Keep defaults; OCR engines will surface the real file/open errors.
145
+ pass
146
 
147
  # 1. Check for EasyOCR (Preferred)
148
  if EASYOCR_AVAILABLE: