light-ocr
Fast, offline OCR for Node.js & C++. PP-OCRv6 with Core ML / WebGPU hardware acceleration — recognize text in images with confidence scores & coordinates. npm:
What is light-ocr?
Fast, offline OCR for Node.js & C++. PP-OCRv6 with Core ML / WebGPU hardware acceleration — recognize text in images with confidence scores & coordinates. npm: @arcships/light-ocr
Overview of light-ocr
What it is
light-ocr is a fast, offline OCR library for Node.js and C++. It uses PP-OCRv6 with Core ML or WebGPU hardware acceleration to recognize text in images, PDFs, or raw pixel data. The npm package includes the OCR model, PDFium renderer, and a Chinese fallback font, all prebuilt for macOS, Linux, and Windows. No postinstall scripts or runtime downloads are required. It returns recognized text lines in reading order with confidence scores and quadrilateral coordinates.
Key features
- Local processing: images, PDFs, and OCR results stay on the machine.
- One package to install: the model, OCR runtime, PDF renderer, and Chinese fallback font are included via the npm package's platform dependency.
- No secondary downloads: installation and runtime need no postinstall fetch, compiler, model download, PDF engine download, or font download.
- Useful output: every line includes recognized text, confidence, and its position in the original image.
- Hardware acceleration by default: auto tries Core ML first on macOS 15+ Apple Silicon, and WebGPU first on Linux and Windows builds.
- Application-friendly execution: recognition runs off the JavaScript main thread and supports queues, cancellation, and explicit cleanup.
- Small text in large images: an optional tiled mode preserves small and dense text in high-resolution images.
Use cases
Local OCR in Node.js applications, command-line tools, desktop software, and native C++ integrations. It can process JPEG, PNG, PDF, encoded bytes, or decoded pixel buffers. The CLI provides commands for recognition, detection, document OCR, and system diagnostics.
Getting started
Node.js 22 or newer is supported. Install the package:bashnpm install @arcships/light-ocrBasic usage in TypeScript:tsimport { createEngine } from '@arcships/light-ocr';import { readFile } from 'node:fs/promises';const engine = await createEngine();try { const result = await engine.recognizeEncoded( await readFile('image.jpg'), ); for (const line of result.lines) { console.log(line.text, line.confidence, line.box); }} finally { await engine.close();}For PDFs:tsimport { recognizeDocument } from '@arcships/light-ocr';for await (const page of recognizeDocument('report.pdf', { dpi: 200 })) { console.log(page.index, page.lines.map((line) => line.text));}
License and pricing
The license is Apache-2.0. The project is open source.
Based on the project's public README and repository metadata.