Skip to content
A Node.js wrapper for the Tesseract OCR API
JavaScript
Branch: master
Clone or download
Latest commit 1757f79 Oct 8, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test async-await Oct 7, 2019
.editorconfig Initial Oct 9, 2018
.eslintrc.js add prettier Oct 4, 2019
.gitignore Initial Oct 9, 2018
.npmignore add prettier Oct 4, 2019
.prettierrc.json add prettier Oct 4, 2019
.travis.yml windows build Oct 7, 2019
LICENSE MIT License Oct 4, 2019
index.js async-await Oct 7, 2019
package-lock.json v1.0.0 Oct 4, 2019
package.json v1.0.0 Oct 4, 2019
readme.md async-await Oct 7, 2019

readme.md

Tesseract OCR for Node.js

Build Status npm npm

Installation

First, you need to install the Tesseract project. Instructions for installing Tesseract for all platforms can be found on the project site. On Debian/Ubuntu:

apt-get install tesseract-ocr

After you've installed Tesseract, you can go installing the npm-package:

npm install node-tesseract-ocr

Usage

const tesseract = require("node-tesseract-ocr")

const config = {
  lang: "eng",
  oem: 1,
  psm: 3,
}

tesseract.recognize("image.jpg", config)
  .then(text => {
    console.log("Result:", text)
  })
  .catch(error => {
    console.log(error.message)
  })

In the config object you can pass any OCR options. Also you can pass here any control parameters or use ready-made sets of config files (like hocr):

const result = await tesseract.recognize("image.jpg", {
  load_system_dawg: 0,
  tessedit_char_whitelist: "0123456789",
  presets: ["tsv"],
})
You can’t perform that action at this time.