tesseract-wrapper

1.1.1 • Public • Published

tesseract-wrapper

Simple module for executing tesseract command to read a base64 image file.

Build Status npm (scoped) npm

PLEASE NOTE

This module is open for public usage, but I have developed it solely for creating an API endpoint on a private VPS. It has a hard dependency of tesseract. You need to have it compiled and its CLI working to use this module. Please read this to help you compile from source or you could use this to try and install it via PPA.

Installation and usage:

$ npm install tesseract-wrapper

then

var tesseract_wrapper = require('tesseract-wrapper')

or (ES6)

import { tesseract-wrapper } from 'tesseract-wrapper'

The API structure

It has a simple method that takes an object with the base64 image data and the langague that tesseract should OCR to

Methods

  • execTesseract: OCRs the base64 image in the language specified in the options parameter

execTesseract

Function to execute tesseract command with the right parameters.

The tasks:

  • 1 - Write image file
  • 2 - Get file path
  • 3 - Exec tesseract
  • 4 - Read outputFile
  • 5 - Delete tempFile
  • 6 - Delete outputFile
  • 7 - Return result object in promise
var tesseract_wrapper = require('tesseract-wrapper');
 
var options = {
  data: Base64String,
  lang: 'eng'
}
 
tesseract_wrapper
  .execTesseract(options)
  .then(result => console.log(result))
  .catch(err => console.log(err))

The log would be:

  { fileContent: '2x" -7x +3 = 0\n(2x -1) (x -3)= 0\n\n' }

How to test it?

To run all unit testing simply do:

npm test

Package Sidebar

Install

npm i tesseract-wrapper

Weekly Downloads

1

Version

1.1.1

License

MIT

Last publish

Collaborators

  • yannunes