Skip to content

墨笔初成,入卷有门 · 0.3.2 CLI, EXIF, ROI, detect, and Electron fix

Latest

Choose a tag to compare

@eric8810 eric8810 released this 22 Jul 11:20

What's new

CLI (N1 entry point)

  • \light-ocr\ bin with
    ecognize\ / \detect\ / \info\ subcommands
  • Implicit recognize: \light-ocr image.png\ = \light-ocr recognize image.png\
  • --format json|jsonl|text, --region, --provider, --no-exif, --schema-version, --quiet\
  • Stable exit codes (64–72) mapped to OcrErrorCode
  • stdout/stderr strict separation

EXIF orientation

  • JPEG orientation tags 1–8 automatically corrected before recognition
  • --no-exif\ flag; \�ppliedTransforms\ in output records the applied state

ROI

  • --region x,y,w,h\ pageSpace rectangle
  • Adapter-layer pixel crop after EXIF correction, box coordinates offset back to full pageSpace
  • Out-of-bounds regions return \invalid_argument\ without clamping

Detect-only

  • \detect\ subcommand: detection boxes without recognition
  • \Engine::detect()\ in Core reuses detection stage, skips recognition
  • \detect --crop\ flag (pending crop bytes implementation)

Envelope schema

  • \schemaVersion: 1\ DocumentResult envelope with stable line/detection IDs
  • --schema-version 1\ for exact output schema

Electron support (from #28)

  • Windows delay-load hook so the native addon loads under Electron and renamed Node-API hosts

Install

\\�ash
npm install @arcships/light-ocr
\\

CLI quick start

\\�ash
light-ocr image.png --format json
light-ocr image.png --format text
light-ocr detect image.png
light-ocr info --version
\\

Node API

\\js
const { createEngine } = require('@arcships/light-ocr');
const engine = await createEngine();
const result = await engine.recognizeEncoded(imageBytes);
console.log(result.lines[0].text);
await engine.close();
\\

Full changelog

See CHANGELOG.md for details.