arcships/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
light‑ocr – Fast, offline OCR for Node.js and C++
What it does – light‑ocr is a library that runs optical‑character‑recognition locally, without sending images to a cloud service. It can read text from JPEG/PNG images, PDFs, or raw pixel buffers and returns each line of text together with a confidence score and the quadrilateral coordinates of the line in the original image.
Who it’s for – Developers building Node.js applications, command‑line tools, desktop software, or native C++ programs that need on‑device OCR. It is especially useful when privacy, low latency, or offline operation are required.
Key features (as described in the README)
- Single‑npm‑install package – The model, OCR runtime, PDF renderer (PDFium), and a Chinese fallback font are bundled. No post‑install scripts, extra downloads, or system‑font dependencies.
- Cross‑platform binaries – Pre‑built native binaries for macOS (Apple Silicon & Intel), Linux (glibc & musl, x64 & arm64), and Windows (x64 & arm64). The Node‑API v8 binding works with Node 22+ (LTS) and newer via ABI compatibility.
- Hardware acceleration – Uses Core ML on recent macOS Apple‑Silicon, WebGPU (Vulkan on Linux, D3D12 on Windows) where available, falling back to CPU otherwise.
- Multiple model tiers – Small (≈30 MB, default, stable), Tiny (≈6 MB, preview, 49 languages, no Japanese), Medium (≈139 MB, preview, higher quality). Install via separate npm tags.
- PDF support – Built‑in PDFium rendering and a fallback Noto Sans SC font, enabling OCR of PDFs that reference Chinese fonts without extra setup.
- Rich output – For each line you get
text,confidence, and a quadrilateralbox. Page‑level metadata and timing information are also provided. - CLI –
light-ocrcommand line tool for quick OCR, region‑of‑interest processing, detection‑only mode, and diagnostics (info,doctor). Supports JSON, JSONL, and plain‑text output. - C++ API – Static library (
light_ocr::core) with CMake target for native integration; accepts decoded pixel formats (GRAY8, RGB8, BGR8, RGBA8). - Agent skill – A ready‑made skill file for AI agents that need to invoke local OCR, with guidance on when to prefer deterministic OCR over multimodal models.
Typical usage (Node.js)
import { createEngine } from "@arcships/light-ocr";
import { readFile } from "node:fs/promises";
const engine = await createEngine();
const result = await engine.recognizeEncoded(await readFile("image.jpg"));
for (const line of result.lines) {
console.log(line.text, line.confidence, line.box);
}
await engine.close();
The same library can stream OCR over PDF pages with recognizeDocument.
Performance – The README cites measured speed‑ups of 2–5× on Apple Silicon (Core ML) and NVIDIA/AMD GPUs via WebGPU compared with pure CPU, and a large reduction in CPU time.
License – Apache 2.0.
Bottom line – light‑ocr is a production‑ready, offline OCR solution that bridges the gap between high‑level JavaScript/Node.js development and low‑level C++ performance, offering hardware acceleration, PDF handling, and easy installation across major desktop platforms.
Related
- Project
- Project
- Project
- Project
- Project