# Image to Text — OCR with line boxes (`hermeskd/image-to-text`) Actor

Image URLs in, the text read from each out: line by line with confidence and bounding boxes, in up to three languages. PNG, JPEG, WebP, TIFF, BMP, GIF. Pay per image.

- **URL**: https://apify.com/hermeskd/image-to-text.md
- **Developed by:** [Logan Parker](https://apify.com/hermeskd) (community)
- **Categories:** Agents, AI, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.60 / 1,000 image reads

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

Give it image URLs (PNG, JPEG, WebP, TIFF, BMP, GIF first frame); it returns the text read from each, line by line with confidence and bounding boxes, in up to three languages. Use it for screenshots, photographed documents, receipts the user gave you, diagrams with labels — anything where the words are pixels your host cannot read. One call returns plain text in reading order plus positions an agent can reason over, and pricing is per image, so a single read costs a fraction of a cent.

### Call it from an agent

Through Apify's MCP server (`https://mcp.apify.com`), tool `call-actor`:

```json
{"actor": "hermeskd/image-to-text", "input": {"urls": ["https://raw.githubusercontent.com/tesseract-ocr/test/main/testing/phototest.tif"]}, "callOptions": {"maxTotalChargeUsd": 0.05, "timeout": 600}, "waitSecs": 30}
```

The call returns the run's status and its `defaultDatasetId`. Read the records with `get-dataset-items`:

```json
{"datasetId": "<defaultDatasetId from the call>", "limit": 50}
```

As a dedicated tool, add `https://mcp.apify.com?tools=hermeskd/image-to-text` to your MCP client. One image finishes well inside the 30-second wait, so one `call-actor` plus one `get-dataset-items` is the whole exchange. `maxTotalChargeUsd` caps what the run can charge; when it is reached the remaining URLs come back as `charge_limit_reached` records and are not charged.

### Input

| Field | Type | Required | Default | Meaning |
|---|---|---|---|---|
| `urls` | array of strings | yes | — | Image URLs (PNG, JPEG, WebP, TIFF, BMP, GIF), http or https, 1–50 per run, up to 20 MB, 50 megapixels and 32,767 pixels on a side each. |
| `languages` | array of strings | no | `["eng"]` | OCR language codes (ISO 639-2); at most 3. Supported: eng, deu, fra, spa, ita, por, nld, pol, ces, swe, dan, nor, fin, tur, rus, ukr. |
| `granularity` | enum `text` · `lines` · `words` | no | `lines` | `text` returns plain text only; `lines` adds each line with its confidence and box; `words` adds each word. |
| `minConfidence` | integer | no | 0 | Drop words read with a confidence below this (0–100), and lines left with no word. |

Every limit above is enforced by the input schema and again in code.

### Output

One record per input URL.

| Field | Meaning |
|---|---|
| `url` | The input URL. |
| `ok` | `true` when the image was read; `false` with `error`. |
| `text` | All text read, in reading order: lines by a newline, paragraphs by a blank line. An image with no readable text gives `ok: true` and an empty string, and is charged — the read was done. |
| `lines` | With `granularity: lines`: each line as `{text, confidence, box: {x, y, w, h}}`, boxes in the image's own pixels. |
| `words` | With `granularity: words`: each word as `{text, confidence, box: {x, y, w, h}}`. |
| `width` | Image width in pixels, after EXIF orientation. |
| `height` | Image height in pixels, after EXIF orientation. |
| `error` | `{code, message}` when `ok` is `false`. |

Example record for the call above, as this Actor returned it in its deploy check on 2026-10-16:

```json
{
  "url": "https://raw.githubusercontent.com/tesseract-ocr/test/main/testing/phototest.tif",
  "ok": true,
  "text": "This is a lot of 12 point text to test the\nocr code and see if it works on all types\nof file format.\n\nThe quick brown dog jumped over the\nlazy fox. The quick brown dog jumped\nover the lazy fox. The quick brown dog\njumped over the lazy fox. The quick\nbrown dog jumped over the lazy fox.",
  "lines": [
    {"text": "This is a lot of 12 point text to test the", "confidence": 96.1, "box": {"x": 36, "y": 92, "w": 544, "h": 30}},
    {"text": "ocr code and see if it works on all types", "confidence": 95.8, "box": {"x": 36, "y": 126, "w": 582, "h": 31}},
    {"text": "of file format.", "confidence": 95.5, "box": {"x": 36, "y": 160, "w": 187, "h": 24}},
    {"text": "The quick brown dog jumped over the", "confidence": 96.1, "box": {"x": 36, "y": 194, "w": 549, "h": 31}},
    {"text": "lazy fox. The quick brown dog jumped", "confidence": 96.2, "box": {"x": 37, "y": 228, "w": 548, "h": 31}},
    {"text": "over the lazy fox. The quick brown dog", "confidence": 96.1, "box": {"x": 36, "y": 262, "w": 561, "h": 31}},
    {"text": "jumped over the lazy fox. The quick", "confidence": 96.3, "box": {"x": 43, "y": 296, "w": 518, "h": 31}},
    {"text": "brown dog jumped over the lazy fox.", "confidence": 96.3, "box": {"x": 37, "y": 330, "w": 524, "h": 31}}
  ],
  "width": 640,
  "height": 480
}
```

### Events and prices

Pay per event; platform usage is included in the price, never passed through.

| Event | Title | Charged when | FREE / BRONZE | SILVER | GOLD / PLATINUM / DIAMOND |
|---|---|---|---|---|---|
| `image-ocr` | Image read | One image read by OCR. | $0.002 | $0.0018 | $0.0016 |

Apify also charges its standard `apify-actor-start` event: $0.00005 per GB of run memory (4 events, $0.0002, at the default 4,096 MB). The minimum maximum-charge a caller can set is $0.01.

Worked example on the FREE tier: 10 screenshots cost 10 × $0.002 = $0.02, plus $0.0002 for the start, $0.0202 in all. Nothing is charged for a failed image.

### Limits and run time

- 1–50 URLs per run; images up to 20 MB, 50 megapixels and 32,767 pixels on a side (Tesseract's own limit — a very long screenshot is refused as `too_large`); TIFF reads its first page and GIF its first frame.
- One image may take at most 120 seconds of OCR; an image that needs longer is answered `too_large`, uncharged.
- Each request — its redirects and its whole body included — must finish within 30 seconds (the per-request timeout; a slower file is `download_failed`); at most 2 requests a second go to one host.
- Images whose longer side is under 1,600 pixels are read at twice their size, which helps the small text of screenshots; boxes are always in the image's own pixels.
- Typical run time: one image in a few seconds; a full 300-dpi page about 3 seconds of OCR at the default memory (4,096 MB, one CPU core). The default run timeout is 600 seconds.

### Errors

Errors are records with `ok: false` and `error.code`; none is charged.

| `error.code` | Meaning |
|---|---|
| `download_failed` | The URL did not return the file (status or network error). |
| `not_image` | Not a supported image (PNG, JPEG, WebP, TIFF, BMP, GIF), or a damaged one that cannot be decoded. |
| `too_large` | Over 20 MB, 50 megapixels or 32,767 pixels on a side, or too dense to read within 120 seconds. |
| `robots_disallowed` | robots.txt forbids fetching the URL. |
| `blocked_host` | The host is on the deny-list, or resolves to a private or local address. |
| `timeout` | The image did not finish within the run's time budget. |
| `internal_error` | Unexpected failure; message carries the class. |
| `charge_limit_reached` | The run reached its maximum total charge before this URL; it was not processed. |
| `invalid_input` | The run input passed the input schema but cannot be used (for example no URL at all); the message names the field. One record per input given, or one with `url: null` when none was given; nothing is processed. |

The run fails only when every input failed with an Actor-side code (`internal_error`, `timeout`), so a broken Actor is visible. Every other run succeeds — including one where nothing was read because of the caller's own inputs (bad URL, robots, deny-list, not an image, invalid input, the charge limit), or where those and Actor-side failures are mixed.

### Sources and terms

The source is the caller's image. Process only images you have the right to process. Fetching follows the Hermes fetch policy: robots.txt is obeyed for the user-agent `HermesBot` (and `*`), and a disallowed URL is refused without a request; platforms whose terms forbid automated access, and people-search sites, are on a deny-list and refused without a request; private and local addresses are refused, after DNS and on every redirect; the user-agent is `HermesBot/1.0 (+https://apify.com/hermeskd)`; no login, cookies, credentials, CAPTCHA solving, evasion or proxies are used. The text read is returned to the caller as it is; no person, face or speaker is identified.

### Not affiliated

This Actor is not affiliated with Google or with the Tesseract project. Tesseract and Pillow are used under their open-source licences.

### Related Hermes Actors

- `pdf-to-markdown` — PDF documents to Markdown, with OCR for scanned pages.
- `document-to-markdown` — Word, PowerPoint, Excel and other office files to Markdown.
- `audio-to-transcript` — speech to text.
- `video-frames` — frames and metadata from a video.
- `image-upscale` — image upscaling.
- `url-to-markdown` — a web page to Markdown.
- `audio-video-convert` — audio and video format conversion.

### Changelog

- 1.0 (2026-10-16) — images over 32,767 pixels on a side and images too dense to read in 120 s are refused as `too_large`; any image Pillow cannot decode is `not_image`.
- 1.0 (2026-10-16) — first release: OCR of six image formats in sixteen languages, text, lines or words with confidence and boxes.

# Actor input Schema

## `urls` (type: `array`):

Image URLs (PNG, JPEG, WebP, TIFF, BMP, GIF), http or https, 1–50 per run, up to 20 MB, 50 megapixels and 32,767 pixels on a side each. Each URL becomes one record.

## `languages` (type: `array`):

OCR language codes (ISO 639-2, e.g. eng, deu, fra); at most 3.

## `granularity` (type: `string`):

text returns plain text only; lines adds each line with its confidence and box; words adds each word with its confidence and box.

## `minConfidence` (type: `integer`):

Drop words read with a confidence below this (0–100), and lines left with no word; 0 keeps everything.

## Actor input object example

```json
{
  "urls": [
    "https://raw.githubusercontent.com/tesseract-ocr/test/main/testing/phototest.tif"
  ],
  "languages": [
    "eng"
  ],
  "granularity": "lines",
  "minConfidence": 0
}
```

# Actor output Schema

## `results` (type: `string`):

One record per input URL with ok, text, lines or words, width, height and error.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "urls": [
        "https://raw.githubusercontent.com/tesseract-ocr/test/main/testing/phototest.tif"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("hermeskd/image-to-text").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "urls": ["https://raw.githubusercontent.com/tesseract-ocr/test/main/testing/phototest.tif"] }

# Run the Actor and wait for it to finish
run = client.actor("hermeskd/image-to-text").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "urls": [
    "https://raw.githubusercontent.com/tesseract-ocr/test/main/testing/phototest.tif"
  ]
}' |
apify call hermeskd/image-to-text --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,hermeskd/image-to-text"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/pAndffsPXq0gNCmJn/builds/OY24WF7paFraX3PLG/openapi.json
