# Image To Image Localization Actor (`gungz/image-to-image-localization-actor`) Actor

Image to Image Text Translation Actor
Translate text within images while preserving the original layout, styling, and visual appearance. This Actor uses Google Cloud Vision API for text detection and Lingo.dev or Gemini AI for high-quality translation.

- **URL**: https://apify.com/gungz/image-to-image-localization-actor.md
- **Developed by:** [Agung Sidharta So](https://apify.com/gungz) (community)
- **Categories:** AI, Automation, Other
- **Security:** Limited permissions
- **Stats:** 5 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.01 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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

## Image to Image Text Translation Actor

Translate text within images while preserving the original layout, styling, and visual appearance. This Actor uses Google Cloud Vision API for text detection and Lingo.dev for high-quality translation with brand voice preservation.

### Features

- 🔍 **Smart Text Detection**: Uses Google Cloud Vision API to detect text with precise bounding boxes
- 🌍 **70+ Languages**: Supports all major languages with regional variants
- 🎨 **Visual Preservation**: Maintains original colors, fonts, and layout
- 📏 **Adaptive Sizing**: Automatically adjusts font size and background for different text lengths
- 🔤 **Alphanumeric Filtering**: Only translates readable text (letters, numbers, spaces)
- 📁 **Batch Processing**: Process up to 100 images in a single run
- 🔄 **Dual Translation Options**: Choose between Gemini AI (default, direct image translation) or Lingo.dev (brand voice preservation)

### How It Works

1. **Text Detection**: Scans the image using Google Cloud Vision API (Lingo.dev mode only)
2. **Smart Filtering**: Only processes alphanumeric text - skips symbols, decorations (Lingo.dev mode only)
3. **Translation**: Choose between Gemini AI (default, direct image translation) or Lingo.dev (brand voice preservation with text detection)
4. **Color Analysis**: Detects original text colors and background patterns (Lingo.dev mode only)
5. **Adaptive Rendering**: Adjusts font size and background based on translation length (Lingo.dev mode only)
6. **AI Quality Check**: Gemini analyzes result for text overlaps and applies fixes (Lingo.dev mode with GEMINI_API_KEY)
7. **Image Composition**: Overlays translated text while preserving visual integrity (Lingo.dev mode)

### Input

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `imageUrls` | Array | Yes | Array of image URLs to translate (up to 100 images per run) |
| `targetLanguage` | String | Yes | Target language (dropdown selection) |
| `translationProvider` | String | No | Translation service: Gemini AI (default) or Lingo.dev (brand voice) |
| `fontSize` | Integer | No | Override font size (8-72px, Lingo.dev only, default: auto-detect) |
| `fontFamily` | String | No | Font family (Lingo.dev only: Arial, Helvetica, Times New Roman, Courier New) |

#### Supported Languages

The Actor supports 70+ languages including:

- **Major Languages**: English, Spanish, French, German, Chinese, Japanese, Arabic, Russian
- **Regional Variants**: en-US, en-GB, es-ES, es-MX, zh-CN, zh-TW, etc.
- **Specialized**: Bavarian, Neapolitan, Tamazight, and more

### Environment Variables

Set these as **secret environment variables** in the Apify Console:

| Variable | Required | Description |
|----------|----------|-------------|
| `GEMINI_API_KEY` | Conditional\* | Gemini API key (required if using Gemini provider) |
| `LINGO_API_KEY` | Conditional\* | Your Lingo.dev API key (required if using Lingo.dev provider) |
| `GOOGLE_CLOUD_CREDENTIALS_JSON` | Conditional\*\* | Google Cloud credentials as JSON string (required for Lingo.dev provider) |

\*Required based on selected translation provider (Gemini is default)
\*\*Only required when using Lingo.dev provider

### Setup Instructions

#### 1. Get API Keys

**Gemini API:**

1. Get API key from [Google AI Studio](https://aistudio.google.com/app/apikey)
2. Set as `GEMINI_API_KEY` environment variable

**Lingo.dev API Key (Optional):**

1. Sign up at [Lingo.dev](https://lingo.dev)
2. Create a new project
3. Generate an API key
4. Set as `LINGO_API_KEY` environment variable

**Google Cloud Vision API (Optional - for Lingo.dev provider):**

1. Create a project in [Google Cloud Console](https://console.cloud.google.com)
2. Enable the Vision API
3. Create a service account with Vision API permissions
4. Download the JSON key file
5. Set as `GOOGLE_CLOUD_CREDENTIALS_JSON` environment variable

**Gemini API (Optional - for Lingo.dev AI enhancement):**

1. Get API key from [Google AI Studio](https://aistudio.google.com/app/apikey)
2. Set as `GEMINI_API_KEY` environment variable for AI image editing with Lingo.dev

#### 2. Configure Environment Variables

In the Apify Console:

1. Go to your Actor settings
2. Add environment variables based on your chosen provider:
   - **For Gemini (default)**: `GEMINI_API_KEY`
   - **For Lingo.dev**: `LINGO_API_KEY` and `GOOGLE_CLOUD_CREDENTIALS_JSON`
   - **Optional**: Add `GEMINI_API_KEY` when using Lingo.dev for AI-powered text overlap fixes

#### 3. Run the Actor

1. Select target language from dropdown
2. Choose translation provider (Gemini AI is default, or Lingo.dev for brand voice)
3. Provide one or more image URLs (up to 100)
4. Optionally adjust font settings (Lingo.dev only)
5. Run the Actor

### Output

The Actor produces:

#### Dataset Items

```json
{
  "originalUrl": "https://example.com/image.jpg",
  "originalType": "url",
  "originalFileName": null,
  "translatedImageUrl": "https://api.apify.com/v2/key-value-stores/.../translated-image.png",
  "targetLanguage": "es-ES",
  "processingTime": 3.2
}
```

#### Key-Value Store

- **Translated Image**: PNG file with translated text overlaid

### Use Cases

- **Marketing Localization**: Translate ads, banners, and promotional materials
- **E-commerce**: Localize product images for international markets
- **Documentation**: Translate screenshots and diagrams
- **Social Media**: Adapt visual content for different regions
- **Website Localization**: Translate UI elements and graphics

### Limitations

- Only processes alphanumeric text (letters, numbers, spaces)
- Requires clear, readable text in images
- Works best with horizontal text layouts
- Very complex backgrounds may affect color detection

### Performance

- **Processing Time**: 5-8 seconds per image with Gemini, 8-12 seconds with Lingo.dev (including AI analysis)
- **Batch Processing**: Up to 100 images per run
- **Supported Formats**: JPEG, PNG, WebP, GIF
- **Max Image Size**: 10MB
- **Concurrent Runs**: Up to 100 (depending on plan)

### Error Handling

Common errors and solutions:

| Error | Cause | Solution |
|-------|-------|----------|
| "No text detected" | Image has no readable text | Use images with clear text |
| "LINGO_API_KEY required" | Missing API key | Set environment variable |
| "Google Cloud credentials not found" | Missing credentials | Set Google Cloud environment variable |
| "No alphanumeric text found" | Only symbols/decorations detected | Use images with letters/numbers |

### Example Usage

#### Via Apify Console

1. Open the Actor in Apify Console
2. Add one or more image URLs
3. Select "Spanish (Spain)" as target language
4. Choose translation provider (Gemini AI is default)
5. Click "Start"

#### Via API

```javascript
const { ApifyApi } = require('apify-client');

const client = new ApifyApi({
    token: 'your-apify-token'
});

const run = await client.actor('your-actor-id').call({
    imageUrls: [
        'https://example.com/image1.jpg',
        'https://example.com/image2.jpg'
    ],
    targetLanguage: 'es-ES',
    translationProvider: 'gemini' // default, or 'lingo'
});

const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item, i) => {
    console.log(`Image ${i + 1}:`, item.translatedImageUrl);
});
```

### Support

- **Documentation**: [Apify Docs](https://docs.apify.com)
- **Community**: [Apify Discord](https://discord.gg/jyEM2PRvMU)
- **Issues**: Create an issue in this repository

### License

This Actor is licensed under the Apache 2.0 License.

# Actor input Schema

## `imageUrls` (type: `array`):

Array of image URLs to translate (up to 100 images per run)

## `targetLanguage` (type: `string`):

Target language code for translation

## `translationProvider` (type: `string`):

Choose translation service: Gemini (AI-powered, default) or Lingo.dev (brand voice preservation)

## `fontSize` (type: `integer`):

Font size for translated text in pixels (only used with Lingo.dev provider)

## `fontFamily` (type: `string`):

Font family for translated text (only used with Lingo.dev provider)

## Actor input object example

```json
{
  "imageUrls": [
    "https://imgv3.fotor.com/images/blog-richtext-image/How-to-Make-Text-Stand-Out-And-More-Readable.jpg"
  ],
  "targetLanguage": "es-ES",
  "translationProvider": "gemini",
  "fontSize": 16,
  "fontFamily": "Arial"
}
```

# Actor output Schema

## `overview` (type: `string`):

No description

## `translatedImages` (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 = {
    "imageUrls": [
        "https://imgv3.fotor.com/images/blog-richtext-image/How-to-Make-Text-Stand-Out-And-More-Readable.jpg"
    ],
    "targetLanguage": "es-ES",
    "translationProvider": "gemini"
};

// Run the Actor and wait for it to finish
const run = await client.actor("gungz/image-to-image-localization-actor").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 = {
    "imageUrls": ["https://imgv3.fotor.com/images/blog-richtext-image/How-to-Make-Text-Stand-Out-And-More-Readable.jpg"],
    "targetLanguage": "es-ES",
    "translationProvider": "gemini",
}

# Run the Actor and wait for it to finish
run = client.actor("gungz/image-to-image-localization-actor").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 '{
  "imageUrls": [
    "https://imgv3.fotor.com/images/blog-richtext-image/How-to-Make-Text-Stand-Out-And-More-Readable.jpg"
  ],
  "targetLanguage": "es-ES",
  "translationProvider": "gemini"
}' |
apify call gungz/image-to-image-localization-actor --silent --output-dataset

```

## MCP server setup

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

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/EMzV5rAZJtuBorulY/builds/QyxSgM6P7Ko1knnKE/openapi.json
