TesseractJs (tesseract_js v0.1.0)

Copy Markdown View Source

Phoenix-friendly wrapper for tesseract.js.

Run OCR in the browser — manga, document scanning, receipt parsing, anything with text in an image — without writing tesseract.js boilerplate. Pick a language, drop two components into your layout, and call getOcrWorker() from JS.

Quick start

# mix.exs
{:tesseract_js, "~> 0.1"}

# config/config.exs
config :tesseract_js, lang: "eng"

# root.html.heex
<TesseractJs.Component.preload />
<TesseractJs.Component.script />

// anywhere in your JS
const { getOcrWorker, recognize } = window.TesseractJs;
const { data } = await recognize(canvasOrImg);
console.log(data.text);

By default everything heavy loads from jsDelivr. To self-host, run:

mix tesseract_js.download eng jpn
# then in config.exs:
config :tesseract_js, source: :local

Modules

Summary

Functions

Default base path under priv/static/ where local-mode assets live.

Returns the merged config map. See TesseractJs.Config.get/1.

Returns the runtime config that the browser needs. See TesseractJs.Config.runtime/1.

Functions

asset_base_path()

Default base path under priv/static/ where local-mode assets live.

config(overrides \\ [])

Returns the merged config map. See TesseractJs.Config.get/1.

runtime_config(overrides \\ [])

Returns the runtime config that the browser needs. See TesseractJs.Config.runtime/1.