const Tesseract = require('tesseract.js'); | |
const fs = require('fs'); | |
const image = process.argv[2]; | |
const lang = process.argv[3]; | |
const saveFilePath = process.argv[4]; | |
Tesseract.recognize( | |
image, | |
lang, | |
{ | |
logger: m => console.log(m) | |
} | |
).then(({ data: { text } }) => { | |
console.log(text); | |
fs.writeFileSync(saveFilePath, text); | |
}).catch(err => { | |
console.error(err); | |
fs.writeFileSync(saveFilePath, 'Error: ' + err.message); | |
}); |