Tesseract OCR via Hot Box containers.
Extract text from images stored at hot:// URLs with optional language,
page segmentation mode (PSM), OCR engine mode (OEM), and output format.
Quick Start
result ::tesseract/ocr("hot://uploads/scan.png")
tap(result.text)
tap(result.url)
// With explicit output path
result ::tesseract/ocr("hot://uploads/scan.png", {
output: "hot://ocr/scan-result.txt",
})
ver ::tesseract/version()
tap(ver.version)
Container Requirements
small
Values
DEFAULT_IMAGE
DEFAULT_IMAGE: Str "alpine:3.21"
INSTALL_CMD
INSTALL_CMD: Str "apk add --no-cache tesseract-ocr tesseract-ocr-data-eng"
Functions
build-ocr-args
fn (input-path: Str, output-base: Str, language: Str?, psm: Int?, oem: Int?, format: Str, dpi: Int?, extra-args: Vec<Str>?): Vec<Str>
Build tesseract CLI arguments (after the tesseract executable name).
Example
::tesseract/build-ocr-args("/data/in.png", "/data/out", "eng", 6, null, "txt", null, null)
// ["/data/in.png", "/data/out", "-l", "eng", "--psm", "6", "txt"]
build-version-args
fn (): Vec<Str>
Build tesseract --version arguments.
Example
::tesseract/build-version-args() // ["--version"]
ocr
fn (input: Str): Map
fn (input: Str, opts: OcrOpts): Map
Run Tesseract OCR on an image in Hot storage.
Returns {text: Str, url: Str, format: Str} where text is extracted
content (for txt/hocr/tsv), url is the output file in Hot storage,
and format is the output format used.
Example
r ::tesseract/ocr("hot://uploads/page.png")
r.text
r.url
r2 ::tesseract/ocr("hot://uploads/page.png", {
language: "eng",
psm: 3,
oem: 1,
format: "txt",
})
small
parse-ocr-output
fn (format: Str, stdout: Str): Str
Parse OCR stdout into text. For txt (and text-like formats), returns
trimmed stdout. PDF output is file-only; returns empty text.
Example
::tesseract/parse-ocr-output("txt", " Hello\n") // "Hello"
::tesseract/parse-ocr-output("pdf", "ignored") // ""
start-ocr
fn (input: Str): Map
fn (input: Str, opts: OcrOpts): Map
Start Tesseract OCR on an image without awaiting the result.
Returns the box task info map immediately. Use ::hot::task/await
to retrieve the final result.
Example
task ::tesseract/start-ocr("hot://uploads/page.png", {format: "txt"})
result ::hot::task/await(task.id)
small
version
fn (): Map
fn (image: Str?): Map
Return the tesseract --version string.
Example
v ::tesseract/version()
v.version
nano
Types
OcrOpts
OcrOpts type {
language: Str?,
psm: Int?,
oem: Int?,
format: Str?,
dpi: Int?,
extra-args: Vec<Str>?,
output: Str?,
image: Str?,
size: Str?,
timeout: Int?
}
Options for OCR.
Fields
language— Tesseract language code(s), e.g."eng","fra","deu+eng"psm— Page segmentation mode (0–13)oem— OCR engine mode (0–3)format— Output:"txt","hocr","tsv","pdf"(default:"txt")dpi— DPI hint for the input image (--dpi)output— Outputhot://URL (default: auto-generated)image— Custom Docker image with tesseract (default:alpine:3.21+ runtime install)size— Box size override (default:"small")