Socket
Socket
Sign inDemoInstall

tesseract.js

Package Overview
Dependencies
Maintainers
3
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tesseract.js

Pure Javascript Multilingual OCR


Version published
Weekly downloads
112K
increased by8.43%
Maintainers
3
Weekly downloads
 
Created

What is tesseract.js?

tesseract.js is a JavaScript library that provides Optical Character Recognition (OCR) capabilities. It allows you to extract text from images and PDFs directly in the browser or in a Node.js environment.

What are tesseract.js's main functionalities?

Basic OCR

This feature allows you to perform basic OCR on an image file. The code sample demonstrates how to recognize text from an image using the English language.

const Tesseract = require('tesseract.js');

Tesseract.recognize(
  'path/to/image.png',
  'eng',
  {
    logger: m => console.log(m)
  }
).then(({ data: { text } }) => {
  console.log(text);
});

Handling Multiple Languages

This feature allows you to recognize text in multiple languages. The code sample demonstrates how to recognize text from an image using both English and Spanish languages.

const Tesseract = require('tesseract.js');

Tesseract.recognize(
  'path/to/image.png',
  'eng+spa',
  {
    logger: m => console.log(m)
  }
).then(({ data: { text } }) => {
  console.log(text);
});

Progress Reporting

This feature provides real-time progress updates during the OCR process. The code sample demonstrates how to log progress messages to the console.

const Tesseract = require('tesseract.js');

Tesseract.recognize(
  'path/to/image.png',
  'eng',
  {
    logger: m => console.log(m)
  }
).then(({ data: { text } }) => {
  console.log(text);
});

Using Worker for Performance

This feature allows you to use a worker for better performance, especially for large images or multiple OCR tasks. The code sample demonstrates how to create a worker, load the necessary language, perform OCR, and then terminate the worker.

const { createWorker } = require('tesseract.js');

const worker = createWorker({
  logger: m => console.log(m)
});

(async () => {
  await worker.load();
  await worker.loadLanguage('eng');
  await worker.initialize('eng');
  const { data: { text } } = await worker.recognize('path/to/image.png');
  console.log(text);
  await worker.terminate();
})();

Other packages similar to tesseract.js

FAQs

Package last updated on 15 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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