Translate Image
Full control over the visual quality and terminological consistency of your images.
Lara Image Translation is an advanced solution designed to translate textual content within images, combining linguistic precision with visual fidelity. Thanks to its flexible architecture, the service offers a choice of four different image translation modes, allowing it to adapt to the specific needs of each project, from simple text extraction to complete image regeneration.
Lara offers four incremental levels of accuracy and visual quality:
- Overlay: Overlays the translated text on the original image, preserving the basic visual context.
- Inpainting: Removes the original text and inserts the translation “in-place,” reconstructing the background for a natural and clean result.
- Generative: The most advanced mode, which regenerates the entire image, including the translated content, for the highest visual quality.
- Image to Text: Extracts text from an image and returns both the transcription and its translation into the target language. It detects the text in the image, preserves the original content, and provides the translated version in a single response.
![]() | ![]() | ![]() | ![]() |
|---|---|---|---|
| Original | Overlay | Inpainting | Generative |
Lara's Image API is fully integrated into our ecosystem and uses your translation memories and glossaries to ensure consistent technical terminology and tone across all projects.
To get the best results, make sure the text is clearly legible. If no language is specified, Lara automatically detects it, making it easy to handle multilingual inputs through a single streamlined API call.
Image to Image
To begin, you must first instantiate the Translator class. This is the mandatory first step for all operations within the Lara SDK.
Translates image from a source language to a target language. It supports context-aware translations and adaptation to specific translation memories, it returns a translated image.
Request
sample_image_path = "sample_image.png"
translated_image = lara.images.translate(
source="en-US",
target="fr-FR",
image_path=sample_image_path,
model="generative"
)const res = await lara.images.translate('path/to/image.jpg', 'en-US', 'it-IT', {
adaptTo: ['mem_1_id', 'mem_2_id'],
glossaries: ['gls_1_id', 'gls_2_id'],
instructions: ['Be formal'],
style: 'fluid',
model:'generative'
});File imageFile = new File("image.jpg");
ImageTranslateOptions options = new ImageTranslateOptions();
options.setAdaptTo("mem_1234...");
options.setGlossaries("gls_1234...");
options.setTextRemoval(ImageTextRemoval.OVERLAY);
InputStream translated = lara.images.translate(imageFile, "en-US", "it-IT", options);$sampleFilePath = __DIR__ . '/sample_image.png';
$sourceLang = "en";
$targetLang = "de";
$translatedStream = $lara->images->translate($sampleFilePath, $sourceLang, $targetLang, new ImageTranslationOptions([
'model' => 'generative'
]));
$outputPath = __DIR__ . '/sample_image_translated.png';
$outputFile = fopen($outputPath, 'w');
stream_copy_to_stream($translatedStream, $outputFile);
fclose($outputFile);
fclose($translatedStream);// Sdk available soon
// Sdk available soon
val imageFile = File("image.jpg")
val options = ImageTranslateOptions().apply {
adaptTo = "mem_1234..."
glossaries = "gls_1234..."
model = ImageTextRemoval.GENERATIVE
}
val translated: InputStream = lara.images.translate(imageFile, "en-US", "it-IT", options)var sampleFilePath = Path.Combine(Directory.GetCurrentDirectory(), "textimage.png");
var sourceLang = "en";
var targetLang = "de";
var translatedStream = await lara.Images.Translate(sampleFilePath, sourceLang, targetLang, options);
var outputPath = Path.Combine(Directory.GetCurrentDirectory(), "sample_image_translated.png");
await using (var fileStream = File.Create(outputPath))
{
await translatedStream.CopyToAsync(fileStream);
}
// Create a MultipartFile from the image data
let file = MultipartFile(filename: "sample_image.png", data: imageData)
let translatedImageData = try await lara.images.translate(
file: file,
source: sourceLang,
target: targetLang,
options: ImageTranslationOptions(model: .generative)
)
// Save the translated image
let outputPath = "./sample_image_translated.png"
try translatedImageData.write(to: URL(fileURLWithPath: outputPath))Here follows the basic fields for the translate method:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| file / imagePath | File / String | Yes | The input image/the path to input image to translate. | |
| source | String | No | The source language code (e.g., "en-EN" for English). If not specified, the system will attempt to detect it automatically. | |
| target | String | Yes | The target language code (e.g., "it-IT" for Italian). This specifies the language you want the image translated into. | |
| options | ImageTranslationOptions | No | See the table below for details. |
Several options are available to customize the behavior of the translate method:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| model | String | No | inpainting | Customize how the original text is removed from the image. Available values: inpainting,overlay,generative |
| adaptTo | String[] | No | Default is all Memories on your account | A list of translation memory IDs for adapting the translation. |
| glossaries | String[] | No | A list of glossary IDs. | |
| noTrace | Boolean | No | False | If true, images and extracted text are retained for 1 hour after the link is sent. Otherwise, they may be retained for up to 7 days under the standard retention policy for reliability and support. |
| style | String | No | faithful | The style to apply to the translation. Available values:faithful,fluid, creative |
Manual text input for generative image
Developers can provide or correct the text used for image regeneration rather than relying exclusively on automatically extracted and translated text. This provides an important control point for image-processing workflows and makes it possible to build automated human-in-the-loop processes:
- An image is analyzed and translated.
- The text is reviewed or corrected when necessary.
- The approved content is then used for final image generation.
Example:
#Extract text with layout, edit a translation, and render it
print("=== Extract, Edit, and Render Translations ===")
text_results = lara.images.translate_text(
source="en-US",
target="es-ES",
image_path=sample_image_path,
include_layout=True
)
print(f"Original image: {os.path.basename(sample_image_path)}")
print(f"Found {len(text_results.paragraphs)} text segments:")
for i, result in enumerate(text_results.paragraphs, 1):
print(f" Segment {i}:")
print(f" Original: {result.text}")
print(f" Translated: {result.translation}")
print()
if text_results.paragraphs:
text_results.paragraphs[0].translation = "¡Hola mundo!"
# include_layout=True guarantees the metadata classic models require.
classic_image = lara.images.render_translated(
image_path=sample_image_path,
source=text_results.source_language,
target="es-ES",
paragraphs=text_results.paragraphs,
model="overlay"
)
with open("sample_image_edited_overlay_es.png", 'wb') as f:
f.write(classic_image)
# Generative models accept text-only paragraphs. Omitting model uses generative_fast.
text_only_paragraphs = [
ImageParagraph(text=p.text, translation=p.translation)
for p in text_results.paragraphs
]
generative_image = lara.images.render_translated(
image_path=sample_image_path,
source=None,
target="es-ES",
paragraphs=text_only_paragraphs
)
with open("sample_image_edited_generative_es.png", 'wb') as f:
f.write(generative_image)//Extract text with layout, edit a translation, and render it
console.log("=== Extract, Edit, and Render Translations ===");
try {
const results = await lara.images.translateText(fs.createReadStream(sampleFilePath), sourceLang, targetLang, {
style: "faithful",
includeLayout: true
});
console.log("✅ Extract and translate completed");
console.log(`Found ${results.paragraphs.length} text blocks`);
results.paragraphs.forEach((result, index) => {
console.log(`\nText Block ${index + 1}:`);
console.log(`Original: ${result.text}`);
console.log(`Translated: ${result.translation}`);
});
if (results.paragraphs.length === 0) {
console.log("No text found to render.");
return;
}
// Replace with your desired translation, keeping all layout metadata.
const editedParagraphs = results.paragraphs.map((paragraph, index) =>
index === 0 ? { ...paragraph, translation: "Hallo Welt!" } : paragraph
);
// Classic models (overlay and inpainting) require bbox, linesBboxes, textInfo,
// and alignment on every paragraph. includeLayout guarantees these fields.
// Open a fresh input stream for each request because streams are consumed.
const classicImage = await lara.images.renderTranslated(
fs.createReadStream(sampleFilePath),
results.sourceLanguage,
targetLang,
editedParagraphs,
"overlay"
);
const classicOutputPath = path.join(__dirname, "edited_image_overlay.png");
await saveImage(classicImage, fs.createWriteStream(classicOutputPath));
console.log(`Edited image saved to: ${path.basename(classicOutputPath)}`);
// Example 4: Generative rendering accepts text-only paragraphs.
// Omit model to use the API default generative_fast, or pass "generative"
// or "generative_fast" explicitly. Pass null to omit the source language.
const textOnlyParagraphs = editedParagraphs.map(({ text, translation }) => ({ text, translation }));
const generativeImage = await lara.images.renderTranslated(
fs.createReadStream(sampleFilePath),
null,
targetLang,
textOnlyParagraphs
);
const generativeOutputPath = path.join(__dirname, "edited_image_generative.png");
await saveImage(generativeImage, fs.createWriteStream(generativeOutputPath));
console.log(`Generative image saved to: ${path.basename(generativeOutputPath)}`);
} catch (error) {
console.log(`Error extracting, editing, or rendering translations: ${error.message}`);
}// Extract and translate text from image (basic)
System.out.println("=== Text Extraction and Translation from Image ===");
try {
ImageTextResult result = lara.images.translateText(sampleImage, "es-ES");
System.out.println("✅ Text extraction and translation completed");
System.out.println("🌍 Detected source language: " + result.getSourceLanguage());
System.out.println("📝 Extracted paragraphs:");
List<ImageParagraph> paragraphs = result.getParagraphs();
for (int i = 0; i < paragraphs.size(); i++) {
ImageParagraph paragraph = paragraphs.get(i);
System.out.println("\n Paragraph " + (i + 1) + ":");
System.out.println(" Original: " + paragraph.getText());
System.out.println(" Translated: " + paragraph.getTranslation());
}
System.out.println();
} catch (LaraException e) {
System.out.println("Error extracting text: " + e.getMessage() + "\n");
return;
}// Extract text with layout, edit a translation, and render it
echo "=== Extract, Edit, and Render Translations ===\n";
try {
$results = $lara->images->translateText($sampleFilePath, $sourceLang, $targetLang, new ImageTextTranslationOptions([
'style' => 'faithful',
'includeLayout' => true
]));
$paragraphs = $results->getParagraphs();
echo "Extract and translate completed\n";
echo "Found " . count($paragraphs) . " text blocks\n";
foreach ($paragraphs as $index => $result) {
echo "\nText Block " . ($index + 1) . ":\n";
echo "Original: " . $result->getText() . "\n";
echo "Translated: " . $result->getTranslation() . "\n";
}
if (empty($paragraphs)) {
echo "No text found to render.\n";
return;
}
// includeLayout=true guarantees complete layout metadata on every paragraph.
$first = $paragraphs[0];
$paragraphs[0] = new ImageLayoutParagraph(
$first->getText(), "Hallo Welt!", $first->getBbox(),
$first->getLinesBboxes(), $first->getTextInfo(), $first->getAlignment(),
$first->getAdaptedToMatches(), $first->getGlossariesMatches()
);
$classicStream = $lara->images->renderTranslated(
$sampleFilePath, $results->getSourceLanguage(), $targetLang, $paragraphs, "overlay"
);
$classicPath = __DIR__ . '/edited_image_overlay.png';
$classicOutput = fopen($classicPath, 'wb');
stream_copy_to_stream($classicStream, $classicOutput);
fclose($classicOutput);
fclose($classicStream);
echo "Edited image saved to: " . basename($classicPath) . "\n";
// Generative models accept text-only paragraphs. Omit model for generative_fast.
$textOnlyParagraphs = array_map(function ($paragraph) {
return new ImageParagraph($paragraph->getText(), $paragraph->getTranslation());
}, $paragraphs);
$generativeStream = $lara->images->renderTranslated(
$sampleFilePath, null, $targetLang, $textOnlyParagraphs
);
$generativePath = __DIR__ . '/edited_image_generative.png';
$generativeOutput = fopen($generativePath, 'wb');
stream_copy_to_stream($generativeStream, $generativeOutput);
fclose($generativeOutput);
fclose($generativeStream);
echo "Edited image saved to: " . basename($generativePath) . "\n";
} catch (LaraException $e) {
echo "Error extracting, editing, or rendering translations: " . $e->getMessage() . "\n";
}// Extract and translate text from an image
fmt.Println("=== Extract and Translate Text ===")
includeLayout := true
results, err := laraTranslator.Images.TranslateTextWithOptions(&sampleFilePath, &sourceLang, targetLang,
&lara.ImageTextTranslateOptions{IncludeLayout: &includeLayout})
if err != nil {
log.Printf("Error extracting and translating text: %v", err)
return
}
fmt.Println("Extract and translate completed")
fmt.Printf("Found %d text blocks\n", len(results.Paragraphs))
for i, result := range results.Paragraphs {
fmt.Printf("\nText Block %d:\n", i+1)
fmt.Printf("Original: %s\n", result.Text)
fmt.Printf("Translated: %s\n", result.Translation)
}
// IncludeLayout guarantees the metadata required by classic rendering models.
// You can edit results.Paragraphs[i].Translation while retaining its layout.
rendered, err := laraTranslator.Images.RenderTranslatedWithOptions(
&sampleFilePath, &results.SourceLanguage, targetLang, results.Paragraphs,
&lara.ImageRenderOptions{Model: lara.TextRemovalOverlay})
if err != nil {
log.Fatal(err)
}
if err := os.WriteFile("rendered_image.png", rendered, 0644); err != nil {
log.Fatal(err)
}// Extract and translate text from image (basic)
println("=== Text Extraction and Translation from Image ===")
try {
val result: ImageTextResult = lara.images.translateText(sampleImage, "es-ES")
println("✅ Text extraction and translation completed")
println("🌍 Detected source language: ${result.sourceLanguage}")
println("📝 Extracted paragraphs:")
result.paragraphs.forEachIndexed { i, paragraph ->
println("\n Paragraph ${i + 1}:")
println(" Original: ${paragraph.text}")
println(" Translated: ${paragraph.translation}")
}
println()
} catch (e: LaraException) {
println("Error extracting text: ${e.message}\n")
return
}// Extract and translate text from an image
Console.WriteLine("=== Extract and Translate Text ===");
try
{
var options = new ImageTextTranslateOptions
{
AdaptTo = new[] { "mem_1A2b3C4d5E6f7G8h9I0jKl" }, // Replace with actual memory IDs
Glossaries = new[] { "gls_1A2b3C4d5E6f7G8h9I0jKl" }, // Replace with actual glossary IDs
Style = TranslationStyle.Faithful,
IncludeLayout = true
};
var results = await lara.Images.TranslateText(sampleFilePath, sourceLang, targetLang, options);
Console.WriteLine("✅ Extract and translate completed");
Console.WriteLine($"Found {results.Paragraphs.Length} text blocks");
for (int i = 0; i < results.Paragraphs.Length; i++)
{
var paragraph = results.Paragraphs[i];
Console.WriteLine($"\nText Block {i + 1}:");
Console.WriteLine($"Original: {paragraph.Text}");
Console.WriteLine($"Translated: {paragraph.Translation}");
}
// IncludeLayout guarantees the metadata required by classic rendering models.
await using var rendered = await lara.Images.RenderTranslated(
sampleFilePath, results.SourceLanguage, targetLang, results.Paragraphs,
ImageTranslationModel.Overlay);
await using var output = File.Create("rendered_image.png");
await rendered.CopyToAsync(output);
}
catch (LaraException e)
{
Console.WriteLine($"Error extracting and translating text: {e.Message}");
}// Extract and translate text from an image
print("=== Extract and Translate Text ===")
// Create another MultipartFile for text extraction
let file3 = MultipartFile(filename: "sample_image.png", data: imageData)
let textOptions = ImageTextTranslationOptions(
adaptTo: ["mem_1A2b3C4d5E6f7G8h9I0jKl"], // Replace with actual memory IDs
glossaries: ["gls_1A2b3C4d5E6f7G8h9I0jKl"], // Replace with actual glossary IDs
style: .faithful,
includeLayout: true
)
let results = try await lara.images.translateText(
file: file3,
source: sourceLang,
target: targetLang,
options: textOptions
)
print("✅ Extract and translate completed")
print("Found \(results.paragraphs.count) text blocks")
// Display each text block and its translation
for (index, paragraph) in results.paragraphs.enumerated() {
print("\nText Block \(index + 1):")
print("Original: \(paragraph.text)")
print("Translated: \(paragraph.translation)")
}
// includeLayout guarantees the metadata required by classic rendering models.
let rendered = try await lara.images.renderTranslated(
file: file3, source: results.sourceLanguage, target: targetLang,
paragraphs: results.paragraphs, model: .overlay
)
try rendered.write(to: URL(fileURLWithPath: "rendered_image.png"))
print("\n🎉 All image translation examples completed successfully!")
} catch {
print("❌ Error: \(error.localizedDescription)")
}Image to text translation
Translates the text inside an image from a source language to a target language. It supports context-aware translations and adaptation to specific translation memories, it returns the original and the translated text.
Request
sample_image_path = "sample_image.png"
text_results = lara.images.translate_text(
source="en-US",
target="es-ES",
image_path=sample_image_path
)const res = await lara.images.translateText('path/to/image.jpg', 'en-US', 'it-IT', {
adaptTo: ['mem_1_id', 'mem_2_id'],
glossaries: ['gls_1_id', 'gls_2_id'],
style: 'fluid'
});File imageFile = new File("image.jpg");
ImageTextTranslateOptions options = new ImageTextTranslateOptions();
options.setAdaptTo("mem_1234...");
options.setGlossaries("gls_1234...");
ImageTextResult result = lara.images.translateText(imageFile, "en-US", "it-IT", options);$sampleFilePath = __DIR__ . '/sample_image.png';
$sourceLang = "en";
$targetLang = "de";
$results = $lara->images->translateText($sampleFilePath, $sourceLang, $targetLang, new ImageTextTranslationOptions([
'adaptTo' => ['mem_1A2b3C4d5E6f7G8h9I0jKl'], // Replace with actual memory IDs
'glossaries' => ['gls_1A2b3C4d5E6f7G8h9I0jKl'], // Replace with actual glossary IDs
'style' => 'faithful'
]));
foreach ($results as $index => $result) {
echo "\nText Block " . ($index + 1) . ":\n";
echo "Original: " . $result->getText() . "\n";
echo "Translated: " . $result->getTranslation() . "\n";
}// Sdk available soon
val imageFile = File("image.jpg")
val options = ImageTextTranslateOptions().apply {
adaptTo = "mem_1234..."
glossaries = "gls_1234..."
}
val result: ImageTextResult = lara.images.translateText(imageFile, "en-US", "it-IT", options)var sampleFilePath = Path.Combine(Directory.GetCurrentDirectory(), "textimage.png");
var sourceLang = "en";
var targetLang = "de";
var options = new ImageTextTranslateOptions
{
AdaptTo = new[] { "mem_1A2b3C4d5E6f7G8h9I0jKl" }, // Replace with actual memory IDs
Glossaries = new[] { "gls_1A2b3C4d5E6f7G8h9I0jKl" }, // Replace with actual glossary IDs
Style = TranslationStyle.Faithful
};
var results = await lara.Images.TranslateText(sampleFilePath, sourceLang, targetLang, options);
for (int i = 0; i < results.Paragraphs.Length; i++)
{
var paragraph = results.Paragraphs[i];
Console.WriteLine($"\nText Block {i + 1}:");
Console.WriteLine($"Original: {paragraph.Text}");
Console.WriteLine($"Translated: {paragraph.Translation}");
}// Create another MultipartFile for text extraction
let file3 = MultipartFile(filename: "sample_image.png", data: imageData)
let textOptions = ImageTextTranslationOptions(
adaptTo: ["mem_1A2b3C4d5E6f7G8h9I0jKl"], // Replace with actual memory IDs
glossaries: ["gls_1A2b3C4d5E6f7G8h9I0jKl"], // Replace with actual glossary IDs
style: .faithful
)
let results = try await lara.images.translateText(
file: file3,
source: sourceLang,
target: targetLang,
options: textOptions
)
// Display each text block and its translation
for (index, paragraph) in results.paragraphs.enumerated() {
print("\nText Block \(index + 1):")
print("Original: \(paragraph.text)")
print("Translated: \(paragraph.translation)")
}Here follows the basic fields for the translateText method:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| file / imagePath | File / String | Yes | The input image/the path to input image to translate. | |
| source | String | No | The source language code (e.g., "en-EN" for English). If not specified, the system will attempt to detect it automatically. | |
| target | String | Yes | The target language code (e.g., "it-IT" for Italian). This specifies the language you want the text translated into. | |
| options | ImageTextTranslationOptions | No | See the table below for details. |
Several options are available to customize the behavior of the translateText method:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| adaptTo | String[] | No | Default is all Memories on your account | A list of translation memory IDs for adapting the translation. |
| glossaries | String[] | No | A list of glossary IDs. | |
| noTrace | Boolean | No | False | If set to True, source content and its translation will not be saved on our system. (AKA Incognito mode) |
| style | String | No | faithful | The style to apply to the translation. Available values:faithful, fluid,creative |
Output
{
"source_language": "it",
"adapted_to": [
"mem_30vccxbs25BqfjoGzYQvgL"
],
"glossaries": null,
"paragraphs": [
{
"text": "BALSAMO PER CAPELLI Fai il pieno d'olio extravergine d'oliva biologico e melone cantalupo fresco per idratare e ammorbidire i capelli dalle radici alle punte e rimetterli in pista.",
"translation": "HAIR CONDITIONER Indulge in organic extra-virgin olive oil and fresh cantaloupe melon to moisturize and soften your hair from root to tip and get it back on track.",
"adapted_to_matches": null,
"glossaries_matches": null
}
]
}Supported languages
Pricing
Details are available in the pricing page
Updated about 1 month ago




