// OCRService.js – 브라우저에서 동작하는 간단 OCR 래퍼(Tesseract.js) // ----------------------------------------------------------------------------- // 이미지 File 객체를 받아 한국어+영어 텍스트를 추출하여 반환한다. // 주의: 브라우저 워커 기반이므로 큰 이미지·다중 호출 시 성능 이슈가 있을 수 있다. // ----------------------------------------------------------------------------- import Tesseract from 'tesseract.js'; /** * @param {File} imageFile - 이미지 파일 객체 * @returns {Promise} 추출 텍스트 (trim 처리) */ const OCRService = async (imageFile) => { try { const { data: { text } } = await Tesseract.recognize(imageFile, 'kor+eng'); return text.trim(); } catch (e) { return ''; } }; export default OCRService;