Files
dsyoon 46460b77f8 init
2025-12-27 14:06:26 +09:00

22 lines
837 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// OCRService.js 브라우저에서 동작하는 간단 OCR 래퍼(Tesseract.js)
// -----------------------------------------------------------------------------
// 이미지 File 객체를 받아 한국어+영어 텍스트를 추출하여 반환한다.
// 주의: 브라우저 워커 기반이므로 큰 이미지·다중 호출 시 성능 이슈가 있을 수 있다.
// -----------------------------------------------------------------------------
import Tesseract from 'tesseract.js';
/**
* @param {File} imageFile - 이미지 파일 객체
* @returns {Promise<string>} 추출 텍스트 (trim 처리)
*/
const OCRService = async (imageFile) => {
try {
const { data: { text } } = await Tesseract.recognize(imageFile, 'kor+eng');
return text.trim();
} catch (e) {
return '';
}
};
export default OCRService;