# node-tesseract-ocr

> A Node.js wrapper for the Tesseract OCR API

Latest version **2.2.1** (published 2021-05-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-tesseract-ocr
pnpm add node-tesseract-ocr
yarn add node-tesseract-ocr
bun add node-tesseract-ocr
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: has types; high quality score.

Warnings: low downloads; no esm support; has vulnerabilities.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.2.1 |
| Published | 2021-05-11 |
| First published | 2018-10-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=10 |
| Dependencies | 0 |
| Unpacked size | 9 KB |
| Known vulnerabilities | 1 |
| Install scripts | no |
| GitHub stars | 320 |
| Maintainers | zapolnoch |
| Keywords | ocr, tesseract, text recognition, optical character recognition, image to text |

## Links

- npm: https://www.npmjs.com/package/node-tesseract-ocr
- Repository: https://github.com/zapolnoch/node-tesseract-ocr
- Homepage: https://github.com/zapolnoch/node-tesseract-ocr#readme
- Issues: https://github.com/zapolnoch/node-tesseract-ocr/issues
- npm.io page: https://npm.io/package/node-tesseract-ocr

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 2.2.1 (latest) — 2021-05-11
- 2.2.0 — 2021-04-27
- 2.1.0 — 2021-04-25
- 2.0.0 — 2020-05-31
- 1.0.0 — 2019-10-07
- 0.2.0 — 2019-10-04
- 0.1.0 — 2018-10-09

## README

# Tesseract OCR for Node.js

[![Build Status](https://img.shields.io/travis/zapolnoch/node-tesseract-ocr/master.svg?style=flat-square)](https://travis-ci.org/zapolnoch/node-tesseract-ocr)
[![npm](https://img.shields.io/npm/v/node-tesseract-ocr.svg?style=flat-square)](https://www.npmjs.com/package/node-tesseract-ocr)
[![npm](https://img.shields.io/npm/dm/node-tesseract-ocr.svg?style=flat-square)](https://www.npmjs.com/package/node-tesseract-ocr)
[![Known Vulnerabilities](https://snyk.io/test/github/zapolnoch/node-tesseract-ocr/badge.svg)](https://snyk.io/test/github/zapolnoch/node-tesseract-ocr)

## Installation

First, you need to install the Tesseract project. Instructions for installing Tesseract for all platforms can be found on [the project site](https://github.com/tesseract-ocr/tessdoc/blob/master/Installation.md). On Debian/Ubuntu:

```bash
apt-get install tesseract-ocr
```

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

```bash
npm install node-tesseract-ocr
```

## Usage

```js
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)
  })
```

Also you can pass Buffer:

```js
const img = fs.readFileSync("image.jpg")

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

or URL:

```js
const img = "https://tesseract.projectnaptha.com/img/eng_bw.png"

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

If you want to process multiple images in a single run, then pass an array:

```js
const images = ["./test/samples/file1.png", "./test/samples/file2.png"]

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

In the config object you can pass any [OCR options](https://github.com/tesseract-ocr/tesseract/blob/master/doc/tesseract.1.asc#options). Also you can pass here any [control parameters](https://tesseract-ocr.github.io/tessdoc/tess3/ControlParams) or use ready-made sets of [config files](https://github.com/tesseract-ocr/tesseract/tree/master/tessdata/configs) (like hocr):

```js
const result = await tesseract.recognize("image.jpg", {
  load_system_dawg: 0,
  tessedit_char_whitelist: "0123456789",
  presets: ["tsv"],
})
```

---
_Source: https://npm.io/package/node-tesseract-ocr · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
