Socket
Socket
Sign inDemoInstall

tesseract.js

Package Overview
Dependencies
Maintainers
4
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tesseract.js - npm Package Compare versions

Comparing version 5.0.5 to 5.1.0

42

docs/faq.md

@@ -10,2 +10,17 @@ FAQ

# Frameworks
## What JavaScript frameworks are supported?
Tesseract.js supports all frameworks that support JavaScript and WebAssembly. The only common JavaScript framework known to not be supported is React Native, as it does not support WebAssembly.
## Why am I getting a `Cannot find module` error when running in my project/framework?
If you are able to run the examples in the [examples directory](https://github.com/naptha/tesseract.js/tree/master/examples), however are getting a `cannot find module` error when run in your framework, this indicates the main Tesseract.js thread is unable to find the worker code.
This can be resolved by manually setting the `workerPath` argument to point to the local copy of `worker-script/node/index.js` (Node.js) or `worker.min.js` (browser). For example, the using the following arguments resolved for one Node.js user in [this issue](https://github.com/naptha/tesseract.js/issues/868#issuecomment-1879235802). You may need to edit the file paths to work with your system/project.
```
const worker = await createWorker("eng", 1, {workerPath: "./node_modules/tesseract.js/src/worker-script/node/index.js"});
```
For context, Tesseract.js "workers" get their own web worker (browser) or worker thread (Node.js), which is independent code that uses a different entry point. When Tesseract.js is used on its own, this entrypoint should be identified automatically. However, this may not hold with build systems implemented by various frameworks, as these build systems copy around files in a way that violates Tesseract.js's assumptions for where files are located.
# Recognizing Text

@@ -20,2 +35,29 @@ ## Are PDF files supported?

## Is handwritten text supported?
No. The Tesseract OCR model is built around assumptions that only hold for printed text. No combination of options will significantly improve performance with handwritten text. Unless your handwriting is so good that it closely resembles printed text, the results will be poor.
## Why am I getting different results vs. Tesseract CLI?
Tesseract.js should produce results identical to using the Tesseract CLI, as long as the settings, language data, and version are identical. If you are observing differences between Tesseract.js and the Tesseract CLI/API, and this difference is problematic, perform the following troubleshooting steps.
1. Confirm parameters are identical.
1. Manually set `oem` and `psm` in both to account for different defaults.
1. Tesseract.js and the Tesseract CLI use different default `oem` and `psm` settings.
1. Tesseract.js uses a default `oem` of `1` (`lstm` model only), while the Tesseract CLI uses a default `oem` of `2` (`lstm` with `legacy` fallback).
2. Tesseract.js and the Tesseract API use a default `pms` of `6` (`PSM_SINGLE_BLOCK`), while the Tesseract CLI uses a default `psm` of `3` (`PSM_AUTO`).
2. Confirm that all user-set parameters are identical.
2. Confirm language data is identical.
1. By default, when run with `oem` value `0` or `2`, Tesseract.js uses [these](https://github.com/naptha/tessdata/tree/gh-pages/4.0.0) language files.
1. These were taken from the [tessdata](https://github.com/tesseract-ocr/tessdata) repo in the main Tesseract project.
3. By default, when run with `oem` value `1`, Tesseract.js uses [these](https://github.com/naptha/tessdata/tree/gh-pages/4.0.0_best_int) language files.
1. These were created by integerizing the language files from the [tessdata_best](https://github.com/tesseract-ocr/tessdata_best) repo in the main Tesseract project.
1. This should be equivalent to using the LSTM language files from the [tessdata](https://github.com/tesseract-ocr/tessdata) which are created by combining an integerized version of `tessdata_best` with data for the Legacy model.
3. Confirm version is identical.
1. Using a different version of Tesseract may result in different recognition results.
2. The exact version of Tesseract used for Tesseract.js can be found by clicking on the `tesseract` submodule in this directory:
1. https://github.com/naptha/tesseract.js-core/tree/master/third_party
If you find that results differ between Tesseract.js and Tesseract CLI and the settings, language data, and version are identical, feel free to open a Git Issue with a reproducible example.
Additionally, feel free to open a Git Issue (with reproducible example) if you find that a **newer** version of Tesseract produces significantly better results, and we can prioritize updating Tesseract to the latest version. If an older version of Tesseract produces significantly better results, then that regression should be raised with the main Tesseract project, as Tesseract.js will not be downgraded to an earlier version.
# Trained Data

@@ -22,0 +64,0 @@ ## How does tesseract.js download and keep \*.traineddata?

4

package.json
{
"name": "tesseract.js",
"version": "5.0.5",
"version": "5.1.0",
"description": "Pure Javascript Multilingual OCR",

@@ -72,3 +72,3 @@ "main": "src/index.js",

"regenerator-runtime": "^0.13.3",
"tesseract.js-core": "^5.0.0",
"tesseract.js-core": "^5.1.0",
"wasm-feature-detect": "^1.2.11",

@@ -75,0 +75,0 @@ "zlibjs": "^0.3.1"

@@ -84,2 +84,17 @@ <p align="center">

## Community Projects and Examples
The following are examples and projects built by the community using Tesseract.js. Officially supported examples are found in the [examples](https://github.com/naptha/tesseract.js/tree/master/examples) directory.
- Projects
- Scribe OCR: web application for scanning documents (images and PDFs)
- Site at [scribeocr.com](https://scribeocr.com/), repo at [github.com/scribeocr/scribeocr](https://github.com/scribeocr/scribeocr)
- Chrome Extension (with Manifest V3): https://github.com/Tshetrim/Image-To-Text-OCR-extension-for-ChatGPT
- Examples
- Converting PDF to text: https://github.com/racosa/pdf2text-ocr
- Use `blocks` output to generate granular data [word/symbol level]: https://github.com/Kishlay-notabot/tesseract-bbox-examples
- Electron: https://github.com/Balearica/tesseract.js-electron
- Typescript: https://github.com/Balearica/tesseract.js-typescript
If you have a project or example repo that uses Tesseract.js, feel free to add it to this list using a pull request. Examples submitted should be well documented such that new users can run them; projects should be functional and actively maintained.
## Major changes in v5

@@ -122,20 +137,2 @@ Version 5 changes are documented in [this issue](https://github.com/naptha/tesseract.js/issues/820). Highlights are below.

## Use tesseract.js the way you like!
- Electron Version: https://github.com/Balearica/tesseract.js-electron
- Typescript: https://github.com/Balearica/tesseract.js-typescript
- Chrome Extension (with Manifest V3): https://github.com/Tshetrim/Image-To-Text-OCR-extension-for-ChatGPT
- Converting PDF to text: https://github.com/racosa/pdf2text-ocr
The following are old examples that use depreciated versions of Tesseract.js. Updating to Tesseract.js v5 is highly recommended. Users are encouraged to create updated examples (or make entirely new ones) and submit them as pull requests.
- Offline Version: https://github.com/jeromewu/tesseract.js-offline
- Firefox Extension: https://github.com/gnonio/korporize
- With Vue: https://github.com/jeromewu/tesseract.js-vue-app
- With Angular: https://github.com/jeromewu/tesseract.js-angular-app
- With React: https://github.com/jeromewu/tesseract.js-react-app
- Video Real-time Recognition: https://github.com/jeromewu/tesseract.js-video
React Native is **not** supported as it does not support Webassembly.
## Contributing

@@ -177,3 +174,3 @@

This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].
This project exists thanks to all the people who contribute. [[Contribute](https://github.com/naptha/tesseract.js?tab=readme-ov-file#contributing)].
<a href="https://github.com/naptha/tesseract.js/graphs/contributors"><img src="https://opencollective.com/tesseractjs/contributors.svg?width=890&button=false" /></a>

@@ -180,0 +177,0 @@

declare namespace Tesseract {
function createScheduler(): Scheduler
function createWorker(langs?: string | Lang[], oem?: OEM, options?: Partial<WorkerOptions>, config?: string | Partial<InitOptions>): Promise<Worker>
function createWorker(langs?: string | string[] | Lang[], oem?: OEM, options?: Partial<WorkerOptions>, config?: string | Partial<InitOptions>): Promise<Worker>
function setLogging(logging: boolean): void

@@ -181,2 +181,7 @@ function recognize(image: ImageLike, langs?: string, options?: Partial<WorkerOptions>): Promise<RecognizeResult>

}
interface RowAttributes {
ascenders: number;
descenders: number;
row_height: number;
}
interface Bbox {

@@ -193,2 +198,3 @@ x0: number;

baseline: Baseline;
rowAttributes: RowAttributes
bbox: Bbox;

@@ -195,0 +201,0 @@ paragraph: Paragraph;

@@ -129,2 +129,12 @@ /**

if (ri.IsAtBeginningOf(RIL_TEXTLINE)) {
// getRowAttributes was added in a recent minor version of Tesseract.js-core,
// so we need to check if it exists before calling it.
// This can be removed in the next major version (v6).
let rowAttributes;
if (ri.getRowAttributes) {
rowAttributes = ri.getRowAttributes();
// Descenders is reported as a negative within Tesseract internally so we need to flip it.
// The positive version is intuitive, and matches what is reported in the hOCR output.
rowAttributes.descenders *= -1;
}
textline = {

@@ -135,2 +145,3 @@ words: [],

baseline: ri.getBaseline(RIL_TEXTLINE),
rowAttributes,
bbox: ri.getBoundingBox(RIL_TEXTLINE),

@@ -137,0 +148,0 @@ };

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc