catalogue / tools / Documents / TIFF to plain text

Convert TIFF to plain text (OCR)

To convert TIFF to plain text (OCR), send one POST to /v1/ocr-image-to-text with the TIFF source. Each call costs $0.005 in USDC on Base via x402, with no account and no API key. The source file can be up to 10 MB.

Endpoint
POST /v1/ocr-image-to-text
Price
$0.005 per call

01Limits

LimitValue
Largest source file10 MB (10,485,760 bytes)
Timeout45 s
Source formatsGIF, JPEG, PNG, TIFF, WebP
Output formatsplain text
Option langone of "eng"; default "eng"

02Example

A real TIFF to plain text run of ocr-image-to-text.

Request
POST /v1/ocr-image-to-text
content-type: application/json
payment-signature: <base64 x402 payload>

{
  "url": "https://grist.tools/samples/images/pair-note.tiff",
  "lang": "eng"
}
Response
200 OK
payment-response: <base64 settlement receipt>

{
  "source_url": "https://grist.tools/samples/images/pair-note.tiff",
  "lang": "eng",
  "image_format": "tiff",
  "text": "SAMPLE SCAN FOR OCR\nSECOND LINE 2026\n",
  "confidence": 86
}

Source file: images/pair-note.tiff, 3.6 KB (3,690 bytes). LZW-compressed TIFF of the same 556x100 raster as ocr-scan.png: two uppercase lines drawn from a hand-written 5x7 bitmap font, SAMPLE SCAN FOR OCR and SECOND LINE 2026. The request sets lang to "eng". The recorded run returned 37 bytes of plain text, 1% of the source size, with a mean OCR confidence of 86 and language eng.

In the sample itself, the little-endian header points to a first image file directory at byte 3,476 with 15 entries; that directory declares 556 by 100 pixels, 3 samples per pixel and compression LZW. The returned text runs to 3 lines, 1 blank one among them, and its longest line, "SAMPLE SCAN FOR OCR", holds 19 characters. Its first line reads "SAMPLE SCAN FOR OCR" and its last "SECOND LINE 2026". Split on whitespace, it yields 7 tokens over 2 non-blank lines.

03Format notes

TIFF as a source

TIFF states its byte order in the first four bytes: II followed by an asterisk and a NUL marks a little-endian file, MM followed by a NUL and an asterisk a big-endian one. image-convert and the OCR detector both accept either order. TIFF can wrap several internal compression schemes; Grist does not inspect them and leaves decoding to the bundled libvips loader, refusing with a typed error a file whose pixels will not decode rather than returning a partial result. Before that, the header dimensions are checked against the shared decoded-pixel budget, which is sized so that a high-resolution page scan still fits while a decompression bomb does not. TIFF is read but not written: image-convert's encode enum has no TIFF entry, so on these pages the format appears only as a source.

plain text as a target

Plain text is recovered in several ways, each tied to one reader. ocr-image-to-text reads pixels with Tesseract running offline from local files, returns a mean confidence with the text, and offers only the languages whose data ships with the service. pdf-to-text returns the existing text layer page by page and performs no OCR. epub-to-text follows the spine's reading order and adds title, creator and language metadata. pptx-to-text returns slide body text in slide order, leaving out speaker notes. html-clean-text extracts article text with Readability by default and returns Markdown in the same response. Because each reader works differently, the text reflects its source: recognised characters with a confidence score from an image, but characters already present in the file from documents and pages.

04Errors

CodeHTTP
invalid_input400
blocked_target403
unreachable_target424
upstream_timeout424
unsupported_content_type415
too_large413
unprocessable422
internal500

When each is raised, and what it means for payment: /docs/ocr-image-to-text.

05Questions

What does it cost to convert TIFF to plain text?
$0.005 per call, paid in USDC on Base via x402.
How large can the TIFF file be?
Up to 10 MB (10,485,760 bytes). Past a limit the call answers too_large (413).
What happens if the conversion fails?
The tool answers with a typed JSON error from the errors table. Payment is settled only after the tool has produced its result; a call that fails inside the tool is never settled.

06Related