🚀 Socket Launch Week 🚀 Day 5: Introducing Socket Fix.Learn More
Socket
Sign inDemoInstall
Socket

tesseract.js-core

Package Overview
Dependencies
Maintainers
4
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tesseract.js-core

Tesseract C++ API in Pure Javascript

6.0.0
latest
Source
npm
Version published
Weekly downloads
180K
5.39%
Maintainers
4
Weekly downloads
 
Created

What is tesseract.js-core?

tesseract.js-core is a JavaScript library that provides core functionalities for optical character recognition (OCR) using the Tesseract OCR engine. It allows developers to extract text from images directly in the browser or in a Node.js environment.

What are tesseract.js-core's main functionalities?

Basic OCR

This code demonstrates how to perform basic OCR using tesseract.js-core. It initializes a worker, loads the necessary language data, and processes an image to extract text.

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

const worker = createWorker({
  corePath: TesseractCore
});

(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();
})();

OCR with Progress Updates

This code sample shows how to perform OCR with progress updates. The logger function is used to log progress messages to the console.

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

const worker = createWorker({
  corePath: TesseractCore,
  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();
})();

OCR with Multiple Languages

This code demonstrates how to perform OCR on an image using multiple languages (English and Spanish in this case).

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

const worker = createWorker({
  corePath: TesseractCore
});

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

Other packages similar to tesseract.js-core

Keywords

ocr

FAQs

Package last updated on 07 Jan 2025

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