Skip to content

Instantly share code, notes, and snippets.

@dannyid
Forked from joemccann/ocr.js
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dannyid/4efa0a5095e283dae2a8 to your computer and use it in GitHub Desktop.
Save dannyid/4efa0a5095e283dae2a8 to your computer and use it in GitHub Desktop.
var ncr = require('nodecr')
, request = require('request')
, fs = require('fs')
, test_img = 'https://www.google.com/images/srpr/logo3w.png' // Change this to your image
// Create image name from end of URL.
// Note this will fail in loads of cases.
var imgName = test_img.split('/').pop()
// Process the image and read the text from it using Tesseract
function ncrHandler(){
ncr.process(__dirname + '/' + imgName,function(err, text){
if(err) return console.error(err)
console.log("Here is the text: \n")
console.log(text)
}, 'eng', 6)
}
// Fetch the image, pipe it to a writeable stream and then fire
// ncrHandler...
request(test_img, ncrHandler).pipe(fs.createWriteStream(imgName))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment