{"size": 791, "ext": "js", "max_stars_repo_path": "index.js", "max_stars_repo_name": "phsantiago/ocr-documents", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "index.js", "max_issues_repo_name": "phsantiago/ocr-documents", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "index.js", "max_forks_repo_name": "phsantiago/ocr-documents", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 37.6666666667, "max_line_length": 149, "alphanum_fraction": 0.7079646018}
var Tesseract = require('tesseract.js')
var request = require('request')
var fs = require('fs')
//var url = 'http://tesseract.projectnaptha.com/img/eng_bw.png'
var url = 'https://conteudo.imguol.com.br/c/entretenimento/ba/2017/12/18/tadeu-schmidt-mostra-sua-carteira-de-motorista-1513629346527_v2_900x506.jpg'
var filename = 'pic.png'

var writeFile = fs.createWriteStream(filename)

var tesseractPromise = Tesseract.create({ langPath: "por.traineddata" })
request(url).pipe(writeFile).on('close', function() {
  console.log(url, 'saved to', filename)
  tesseractPromise.recognize(filename, 'eng')
    .progress(function  (p) { console.log('progress', p)  })
    .catch(err => console.error(err))
    .then(function (result) {
      console.log(result.text)
      process.exit(0)
    })
});
