# Image Text Extractor (`m3web/image-text-extractor`) Actor

Extract text from images using OCR (Optical Character Recognition) via direct URLs or uploaded JSON/CSV files. Works with multiple languages and automatically enriches your structured file with the text found inside images.

- **URL**: https://apify.com/m3web/image-text-extractor.md
- **Developed by:** [M3Web](https://apify.com/m3web) (community)
- **Categories:** AI, E-commerce, Automation
- **Stats:** 91 total users, 5 monthly users, 100.0% runs succeeded, 5 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

$2.90/month + usage

To use this Actor, you pay a monthly rental fee to the developer. The rent is subtracted from your prepaid usage every month after the free trial period. You also pay for the Apify platform usage, which gets cheaper the higher Apify subscription plan you have.

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

## 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

## 🖼️ Image Text Extractor

Extract text from images using OCR (Optical Character Recognition) via direct URLs or uploaded JSON/CSV files. Works with multiple languages and automatically enriches your structured file with the text found inside images.

***

### ✅ Features

- Accepts **image URLs** either:
  - Directly through `startUrls`, or
  - From uploaded `.json` or `.csv` files
- Applies **OCR (Optical Character Recognition)** to each image and extracts:
  - `extractedText`: Full raw text detected
  - `paragraphs`: Text split into readable blocks
  - `urls`: Any links found within the image text
- Supports **Tesseract OCR** with multiple languages (e.g. English, German, Spanish, etc.)
- Saves results in Apify **Key-Value Store** with a shareable download link
- Logs are clean and easy to follow

***

### 📥 Input

This Actor accepts these input fields:

| Field              | Type     | Description                                                                 |
|-------------------|----------|-----------------------------------------------------------------------------|
| `Image URLs`        | `array`  | (Optional) One or more direct image URLs to process                         |
| `Upload a structured file`| `file`   | (Optional) Upload a `.json` or `.csv` file that contains image URLs          |
| `Field name for image URL`      | `string` | The name of the column or field in your file that holds the image URLs      |
| `language`         | `string` | Choose the OCR language from the dropdown (default is English)  |

#### 👇 Explaining `Field name for image URL` in simple terms

If you're uploading a `.json` or `.csv` file, you need to tell the Actor which part of each item contains the image URL. This is what the `Field name for image URL` is for:

- 🔢 In a **CSV file**, each column has a name (like `"image_url"` or `"photo"`). You should type in the exact column name where the image URL is located.
  - Example:
    ```csv
    title,image_url
    Product 1,https://example.com/image1.jpg
    Product 2,https://example.com/image2.jpg
    ```
    In this case, you'd set `Field name for image URL` to <u>**image_url**</u>.

- 🧱 In a **JSON file**, each object has a label for its fields. You need to write the name of the field that stores the image link.
  - Example:
    ```json
    [
      { "name": "Item A", "photo": "https://example.com/photo.jpg" }
    ]
    ```
    Here, you'd set `Field name for image URL` to <u>**photo**</u>.

- 💬 You can also use dot notation to reach inside nested fields. For example, if your JSON file looks like this:
  - Example:
    ```json
    [
      { "assets": { "image": "https://example.com/image.jpg" } }
    ]
    ```
    Then set `Field name for image URL` to <u>**assets.image**</u>.

- 🔢 Multiple Images in One Row

  If your `.json` or `.csv` file contains **more than one image URL per item**, you can still process them all! Simply point to the field that holds an array of URLs.

  - Example `.json` input:

    ```json
    {
      "title": "Product Set",
      "images": [
        "https://example.com/photo1.jpg",
        "https://example.com/photo2.jpg"
      ]
    }
    ```

    Set `Field name for image URL` to <u>**images**</u> — the Actor will automatically process **all image URLs** inside that array.

    This also works with dot notation for nested arrays:

    ```json
    {
      "media": {
        "photos": [
          "https://example.com/one.jpg",
          "https://example.com/two.jpg"
        ]
      }
    }
    ```

    In this case, set `Field name for image URL` to <u>**media.photos**</u>

***

#### 🌍 OCR Language

The Actor supports many languages beyond English. At the input step, you'll see a **dropdown menu** labeled `language`. Select the appropriate language for your images (e.g. German, French, Spanish...) - the default language is English.

This helps the OCR engine correctly detect and read the text in your image.

***

### 📤 Output

After processing, you'll receive:

1. A structured **CSV or JSON file** with enriched data:
   - `extractedText`: All text found in each image
   - `paragraphs`: Text broken into readable chunks
   - `urls`: Any links found inside the image text

2. 📎 Your enriched file is saved in the run’s **Apify Key-Value Store**.
   - The Actor logs a Console link to the store (e.g., `https://console.apify.com/storage/key-value-stores/<STORE_ID>`).
   - From there, you can download the record named `ocr_result.json` or `ocr_result.csv`.

3. 📊 OCR results are also pushed to the Apify Dataset (optional), so you can export them in JSON, CSV, or Excel formats.

***

### 🚀 Example Use Cases

- Extracting text from screenshot-based Google Ads
- Enriching scraped product data with visible text
- Identifying links or CTAs from image banners

***

### 🤖 Behind the Scenes

This Actor uses:

- Tesseract.js for OCR
- Sharp for image preprocessing (grayscale, normalize)
- Support for both in-memory JSON and CSV parsing/stringifying
- Output is clean and downloadable, with clear logs and no clutter

### 💡 Tip

Want to extract thousands of image ads from Google’s Ad Transparency Center? Combine this with a crawler that scrapes `adstransparency.google.com`, then feed that structured JSON into this Actor. Boom — text from image ads, at scale.

# Actor input Schema

## `startUrls` (type: `array`):

Paste one or more direct image URLs (e.g. PNG, JPG, WebP). Each will be OCR processed.

## `uploadedDataFile` (type: `string`):

Upload a JSON or CSV file that contains image URLs in one column or object field.

## `urlFieldName` (type: `string`):

Name of the field (JSON) or column (CSV) that holds image URLs (e.g. 'image', 'img_link').

## `language` (type: `string`):

Select the OCR language (Tesseract 3-letter code)

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://screentest.app/images/example-ocr.png"
    }
  ],
  "urlFieldName": "image_url",
  "language": "eng"
}
```

# Actor output Schema

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

No description

## `enrichedFileConsole` (type: `string`):

No description

## `notes` (type: `string`):

No description

# 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 = {
    "startUrls": [
        {
            "url": "https://screentest.app/images/example-ocr.png"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("m3web/image-text-extractor").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 = { "startUrls": [{ "url": "https://screentest.app/images/example-ocr.png" }] }

# Run the Actor and wait for it to finish
run = client.actor("m3web/image-text-extractor").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 '{
  "startUrls": [
    {
      "url": "https://screentest.app/images/example-ocr.png"
    }
  ]
}' |
apify call m3web/image-text-extractor --silent --output-dataset

```

## MCP server setup

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

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/T9emPKxYt5d6SxxbX/builds/JAGMr9pABaSx9wgfZ/openapi.json
