catalogue / tools / Documents / WebP to plain text

Convert WebP to plain text (OCR)

To convert WebP to plain text (OCR), send one POST to /v1/ocr-image-to-text with the WebP 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 WebP 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.webp",
  "lang": "eng"
}
Response
200 OK
payment-response: <base64 settlement receipt>

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

Source file: images/pair-note.webp, 248 bytes. Lossless WebP 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, 15% of the source size, with a mean OCR confidence of 86 and language eng.

In the sample itself, the RIFF header counts 240 bytes after itself and the one chunk is a lossless VP8L bitstream of 227 bytes for 556 by 100 pixels, with the alpha hint clear. 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

WebP as a source

WebP can hold lossy or lossless imagery, alpha and animation inside a RIFF container. Grist checks for RIFF at byte zero and WEBP at byte eight; the second test matters because WAV and AVI files also open with RIFF and differ only in that form type. image-convert and ocr-image-to-text each perform the check themselves before any decoder runs. For conversion, sharp opens the file with animated decoding off, so an animated WebP contributes only its first frame, and the header dimensions are compared with the shared pixel budget beforehand. The output does not record whether the source was lossy or lossless: image-convert re-encodes the decoded pixels and drops metadata. A lossless WebP therefore hands exact pixel values to the target encoder, whereas a lossy one passes its own artefacts along.

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 WebP to plain text?
$0.005 per call, paid in USDC on Base via x402.
How large can the WebP 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