# react-native-tesseract-ocr

> Tesseract OCR wrapper for React Native

Latest version **2.0.3** (published 2021-06-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-tesseract-ocr
pnpm add react-native-tesseract-ocr
yarn add react-native-tesseract-ocr
bun add react-native-tesseract-ocr
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.0.3 |
| Published | 2021-06-25 |
| First published | 2016-09-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 39.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 594 |
| Author | Jonathan Palma |
| Maintainers | jonathanpalma |
| Keywords | react-native, tesseract ocr, optical character recognition, cognitive services, text recognizer |

## Links

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

## Recent versions

- 2.0.3 (latest) — 2021-06-25
- 2.0.1 — 2020-08-10
- 2.0.0 — 2020-07-15
- 1.0.10 — 2018-03-07
- 1.0.9 — 2018-01-03
- 1.0.8 — 2017-02-13
- 1.0.7 — 2017-02-13
- 1.0.6 — 2016-10-21
- 1.0.5 — 2016-09-30
- 1.0.4 — 2016-09-17
- 1.0.3 — 2016-09-17
- 1.0.2 — 2016-09-17
- 1.0.1 — 2016-09-17

## README

<div align="center">
  <h1>react-native-tesseract-ocr 👀</h1>
  <p>
  react-native-tesseract-ocr is a react-native wrapper for <a href="https://github.com/tesseract-ocr">Tesseract OCR</a>
  </p>
</div>

[![Version][version-badge]][package]
[![Install Size][size-badge]][package-size]
[![Downloads][downloads-badge]][npmcharts]
[![PRs Welcome][prs-badge]][prs]
[![Commitizen friendly][cz-badge]][cz]
[![MIT License][license-badge]][license]
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

[![Watch on GitHub][github-watch-badge]][github-watch]
[![Star on GitHub][github-star-badge]][github-star]
[![Tweet][twitter-badge]][twitter]

This project uses:

- [tess-two][url-tess-and] for Android
- [Tesseract-OCR-iOS][url-tess-ios] for iOS ⚠️ (This has NOT been implemented yet) ⚠️

NOTE: It is recommended to use react-native >= 0.60.0

## Getting started

`$ npm i react-native-tesseract-ocr --save`

### Mostly automatic installation

`$ react-native link react-native-tesseract-ocr`


## Example


<div align="center">
  <img src="https://raw.githubusercontent.com/jonathanpalma/react-native-tesseract-ocr/master/example/showcase.android.picker.gif" alt="Showcase Android using Picker" width="215" height="430" style="margin: 0px 10px" />
  <img src="https://raw.githubusercontent.com/jonathanpalma/react-native-tesseract-ocr/master/example/showcase.android.camera.gif" alt="Showcase Android using Camera" width="215" height="430" style="margin: 0px 10px" />
</div>

Check the example by yourself [here][url-example]

## Usage

### tessOptions

| Property  | Type     | Description                                                                |
| --------- | -------- | -------------------------------------------------------------------------- |
| allowlist | `string` | List of characters you want to recognize                                   |
| denylist  | `string` | List of characters you DON'T want to recognize                             |
| level     | `Level`  | Level of the tokens of the page hierarchy (only used in `recognizeTokens`) |

_`Level` can be one of the following values 'symbol' | 'block' | 'line' | 'paragraph' | 'word'_

### recognize

```typescript
import TesseractOcr, { LANG_ENGLISH } from 'react-native-tesseract-ocr';

const tessOptions = {};
TesseractOcr.recognize(imageSource, LANG_ENGLISH, tessOptions);
```

### recognizeTokens

```typescript
import TesseractOcr, { LANG_ENGLISH, LEVEL_WORD } from 'react-native-tesseract-ocr';

const tessOptions = { level: LEVEL_WORD };
TesseractOcr.recognizeTokens(imageSource, LANG_ENGLISH, tessOptions);
```


### useEventListener

```typescript
import React, { useState } from 'react';
import { useEventListener } from 'react-native-tesseract-ocr';

function App() {
  const [progress, setProgress] = useState(0);
  useEventListener('onProgressChange', (p) => {
    setProgress(p.percent / 100);
  });

  // return ...
}
```



## Contributing

### How to contribute?

This is a `commitizen friendly` repository, so instead of creating commits using `git commit`, please use our custom CLI by running:

`$ npm run cz`

## Contributors ✨

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
  <tr>
    <td align="center"><a href="http://jonathanpalma.me"><img src="https://avatars3.githubusercontent.com/u/12414771?v=4" width="100px;" alt=""/><br /><sub><b>Jonathan Palma</b></sub></a><br /><a href="https://github.com/jonathanpalma/react-native-tesseract-ocr/commits?author=jonathanpalma" title="Code">💻</a> <a href="https://github.com/jonathanpalma/react-native-tesseract-ocr/commits?author=jonathanpalma" title="Documentation">📖</a> <a href="#example-jonathanpalma" title="Examples">💡</a></td>
    <td align="center"><a href="https://github.com/jrunestone"><img src="https://avatars3.githubusercontent.com/u/2293001?v=4" width="100px;" alt=""/><br /><sub><b>Johan Runsten</b></sub></a><br /><a href="https://github.com/jonathanpalma/react-native-tesseract-ocr/commits?author=jrunestone" title="Code">💻</a></td>
  </tr>
</table>

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!

## License

MIT © [jonathanpalma](https://github.com/jonathanpalma)

This library wouldn't be possible without these amazing projects:

- [Tesseract OCR][url-tesseract] - [Apache 2.0 license][url-tesseract-lsc]
- [tess-two][url-tess-and] - [Apache 2.0 license][url-tess-and-lsc]
<!-- - [Tesseract-OCR-iOS][url-tess-ios] - [MIT license][url-tess-ios-lsc] -->

[downloads-badge]: https://img.shields.io/npm/dm/react-native-tesseract-ocr.svg?style=flat-square
[license-badge]: https://img.shields.io/npm/l/react-native-tesseract-ocr.svg?style=flat-square
[license]: https://github.com/jonathanpalma/react-native-tesseract-ocr/blob/master/LICENSE
[npmcharts]: http://npmcharts.com/compare/react-native-tesseract-ocr
[package-size]: https://packagephobia.now.sh/result?p=react-native-tesseract-ocr
[package]: https://www.npmjs.com/package/react-native-tesseract-ocr
[prs-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square
[prs]: http://makeapullrequest.com
[cz-badge]: https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=flat-square
[cz]: http://commitizen.github.io/cz-cli/
[size-badge]: https://flat.badgen.net/packagephobia/install/react-native-tesseract-ocr
[version-badge]: https://img.shields.io/npm/v/react-native-tesseract-ocr.svg?style=flat-square
[github-watch-badge]: https://img.shields.io/github/watchers/jonathanpalma/react-native-tesseract-ocr.svg?style=social
[github-watch]: https://github.com/jonathanpalma/react-native-tesseract-ocr/watchers
[github-star-badge]: https://img.shields.io/github/stars/jonathanpalma/react-native-tesseract-ocr.svg?style=social
[github-star]: https://github.com/jonathanpalma/react-native-tesseract-ocr/stargazers
[url-example]: https://github.com/jonathanpalma/react-native-tesseract-ocr/tree/master/example
[url-eslint]: https://eslint.org/
[url-prettier]: https://prettier.io/
[url-tesseract]: https://github.com/tesseract-ocr/tesseract
[url-tesseract-lsc]: https://github.com/tesseract-ocr/tesseract/blob/master/LICENSE
[url-tess-and]: https://github.com/rmtheis/tess-two
[url-tess-and-lsc]: https://github.com/rmtheis/tess-two/blob/master/COPYING
[url-tess-ios]: https://github.com/gali8/Tesseract-OCR-iOS
[url-tess-ios-lsc]: https://github.com/gali8/Tesseract-OCR-iOS/blob/master/LICENSE.md
[twitter]: https://twitter.com/intent/tweet?text=Check%20out%20react-native-tesseract-ocr!%20https://github.com/jonathanpalma/react-native-tesseract-ocr
[twitter-badge]: https://img.shields.io/twitter/url/https/github.com/jonathanpalma/react-native-tesseract-ocr.svg?style=social

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