evo-ocr-preprocess-extract
Preprocesses receipt images using Pillow (grayscale, upscaling, contrast enhancement, binarization) and extracts raw text using pytesseract with optimal PSM configuration for receipt layouts.
Key Functions
get_sorted_image_files(directory_path)- Returns sorted list of (filename, full_path) tuplespreprocess_image(image_path, scale_factor=2, contrast_factor=2.0, threshold=140)- Preprocesses image for OCRextract_text_from_image(image_path, psm=4, oem=3, ...)- Extracts text with preprocessing + Tesseractextract_text_multi_config(image_path)- Tries multiple configs for best result
Usage
pythonimport sys sys.path.insert(0, '/app/environment/skills/evo-ocr-preprocess-extract/scripts') from utils import get_sorted_image_files, extract_text_from_image files = get_sorted_image_files('/path/to/images') for filename, filepath in files: text = extract_text_from_image(filepath)
Pipeline
- Grayscale conversion (handles RGBA/RGB)
- 2x upscale with LANCZOS resampling
- Contrast enhancement (factor 2.0)
- Median filter denoising
- Binarization (threshold 140)
- Tesseract OCR with PSM 4 (single column)


