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: :localModules
TesseractJs.Models— language registry + URL builders.TesseractJs.Config— config defaults and runtime resolution.TesseractJs.Component—<.preload />and<.script />HEEx components.Mix.Tasks.TesseractJs.Download—mix tesseract_js.downloadtask.
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
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.