0.4.0 • Published 7 years ago

penteract v0.4.0

Weekly downloads
5
License
MIT
Repository
github
Last release
7 years ago

Build Status Coverage

penteract

The native Node.js bindings to the Tesseract OCR project.

ATTENSION that this package is still Working In Progress, and only support Mac OS X for now.

Contributions are welcome.

Install

First of all, a g++ 4.9 compiler is required.

Before install penteract, the following dependencies should be installed

$ brew install pkg-config tesseract # mac os

Then npm install

$ npm install penteract

To use with Electron

Due to the limitation of node native modules, if you want to use penteract with electron, add a .npmrc file to the root of your electron project, before npm install:

runtime = electron
; the version of the local electron,
; use `npm ls electron` to figure out the version
target = 1.7.5
target_arch = x64
disturl = https://atom.io/download/atom-shell

Usage

Recognize an Image Buffer

import {
  recognize
} from 'penteract'

import fs from 'fs-extra'

const filepath = path.join(__dirname, 'test', 'fixtures', 'penteract.jpg')

fs.readFile(filepath).then(recognize).then(console.log) // 'penteract'

Recognize a Local Image File

import {
  fromFile
} from 'penteract'

fromFile(filepath, {lang: 'eng'}).then(console.log)     // 'penteract'

recognize(image , options)

  • image Buffer the content buffer of the image file.
  • options PenteractOptions= optional

Returns Promise.<String>

fromFile(filepath , options)

  • filepath Path the file path of the image file.
  • options PenteractOptions=

Returns Promise.<String> the recognized text.

PenteractOptions Object

{
  // type `(String|Array.<String>)=eng`,
  // Specifies language(s) used for OCR. Run `tesseract --list-langs` in command line for all supported languages. Defaults to `'eng'`.
  lang: 'eng'
}

License

MIT

0.4.0

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.0

7 years ago