Image translation-standard edition

Updated at:

Translates text in images while preserving the original layout. This service uses a synchronous call to return the translated image's URL. You can also enable the editor protocol by setting UseImageEditor to true to retrieve layer information such as text position, font, and color. For higher translation quality and automatic source language detection, use Image Translation-Pro Edition.

Overview

The Image Translation service is designed specifically for e-commerce images and supports over 400 language pairs. It accurately handles complex text layouts within images and ensures that translated content matches the visual context. This allows e-commerce platforms and developers to easily localize and display visual content for global audiences.

Use cases

Ideal for e-commerce product images, marketing materials, and other image-based content.

Features

  • Main product subject protection: You can choose not to translate text on the main product subject. This feature protects embedded information, such as product names, from being translated.

  • Brand name protection: You can choose not to translate brand names in an image. This preserves brand identity by preventing brand names from being translated.

  • Translation intervention: Customize translation results with a glossary. You can define rules for specific terms, such as do-not-translate (for example, ABC remains ABC), forced translation (ABC becomes DEF), and deletion (ABC becomes an empty string). This is commonly used for brand name protection. To apply these rules, pass a glossary ID in your request. A glossary can typically contain up to 100,000 entries. If you need a larger capacity, contact us.

  • Layer information (editor protocol): When you set UseImageEditor to true, the response includes additional layout details such as text position, font, and color. You can use this information for post-editing. For a complete description of the fields, see the Image Translation editor protocol.

API

With this synchronous interface, you submit an image URL with the source and target languages to directly retrieve the translated image's URL.

POST /rest/ai/image/translation

Quick start

import json

data = json.dumps({
    "ImageUrl": "https://example.com/product-image.jpg",
    "SourceLanguage": "en",
    "TargetLanguage": "ko"
})

result = make_signed_request("/rest/ai/image/translation", data)
print(result["Data"]["ImageUrl"])  # URL of the translated image

Request parameters

Parameter

Type

Required

Description

ImageUrl

String

Yes

• Image URL: The URL must be publicly accessible.

• Format: PNG, JPEG, JPG, BMP, or WEBP.

• Dimensions: The width and height must not exceed 4,000 pixels.

• File size: The original file size must be 10 MB or less.

SourceLanguage

String

Yes

The source language code. For a list of supported language pairs, see Supported language pairs below. Example: "en".

TargetLanguage

String

Yes

The target language code. For a list of supported language pairs, see Supported language pairs below. Example: "ko".

IncludingProductArea

Boolean

No

Specifies whether to translate text on the main product subject. The default value is false, which means only text outside the main subject area is translated.

TranslatingBrandInTheProduct

Boolean

No

Specifies whether to translate brand names in the image. The default value is false, which prevents their translation to preserve brand identity.

Glossary

String

No

The ID of the glossary. You must create the glossary in the console in advance and provide its ID in this parameter. If this parameter is empty, the translation results are not modified.

Example: "glossary_1"

UseImageEditor

Boolean

No

Specifies whether to return layout information (layer information), such as the position, font, and color of the text. If this parameter is set to true, the response additionally returns the Data.GenFiles editor protocol, which can be integrated with an image editor for further editing. The default value is false. For a complete field description, see Image Translation Editor Protocol.

Request example

{
  "ImageUrl": "https://example.com/your-image.jpg",
  "SourceLanguage": "en",
  "TargetLanguage": "vi",
  "IncludingProductArea": true,
  "TranslatingBrandInTheProduct": true,
  "Glossary": null,
  "UseImageEditor": true
}

Response fields

Field

Type

Description

Code

String

The business status code. success indicates a successful operation.

Message

String

The status description. The value is Success for a successful operation, or an error message for a failed operation.

Success

Boolean

Indicates if the request succeeded. true for success; false for failure.

RequestId

String

The unique ID for the request.

Data.ImageUrl

String

The URL of the translated image.

Data.UsageMap.ProcessedImageCount

Number

The number of images processed (usage).

Data.GenFiles

Array[Object]

An array of editor protocols (returned only when UseImageEditor=true). Each element contains SrcImage, EditInfo, and ResultList.

For a complete field description, see Image Translation editor protocol.

Editor protocol fields (Data.GenFiles)

When UseImageEditor=true, the response also returns the following fields. For more information, see Image Translation Editor Protocol.

No.

Parameter name

Data type

Description and example value

1

Data.GenFiles

Array[Object]

The editor protocol information. This is returned only when UseImageEditor is true.

2

Data.GenFiles.SrcImage

String

The URL of the original image.

3

Data.GenFiles.EditInfo

Object

Detailed editor information.

4

Data.GenFiles.EditInfo.ResultImageIds

Array[String]

A collection of global IDs for the translated images.

5

Data.GenFiles.EditInfo.RepairedUrl

String

The URL of the image after all text has been inpainted.

6

Data.GenFiles.EditInfo.Languages

Array[String]

A list of translated languages.

7

Data.GenFiles.EditInfo.TextAreas

Array[Object]

A list of text boxes.

8

Data.GenFiles.EditInfo.TextAreas.Fontsize

Number

The font size.

9

Data.GenFiles.EditInfo.TextAreas.Content

String

The original text before translation.

10

Data.GenFiles.EditInfo.TextAreas.Color

String

The text color, such as #ffffff.

11

Data.GenFiles.EditInfo.TextAreas.VerticalLayout

String

Vertical alignment: center, top, or down.

12

Data.GenFiles.EditInfo.TextAreas.HorizontalLayout

String

Horizontal alignment: center, left, or right.

13

Data.GenFiles.EditInfo.TextAreas.LineCount

Number

The number of lines in the text box.

14

Data.GenFiles.EditInfo.TextAreas.Texts

Array[Object]

A list of translated text objects.

15

Data.GenFiles.EditInfo.TextAreas.Texts.Fontsize

Number

The font size.

16

Data.GenFiles.EditInfo.TextAreas.Texts.Language

String

The language.

17

Data.GenFiles.EditInfo.TextAreas.Texts.Valid

Boolean

Indicates if the text item is valid.

18

Data.GenFiles.EditInfo.TextAreas.Texts.ImageRect

Object

The inpainted area of the image.

19

Data.GenFiles.EditInfo.TextAreas.Texts.TextRect

Object

The area of the text box.

20

Data.GenFiles.EditInfo.TextAreas.Texts.Color

String

The color.

21

Data.GenFiles.EditInfo.TextAreas.Texts.Value

String

The translated text.

22

Data.GenFiles.EditInfo.TextAreas.Texts.VerticalLayout

String

The vertical alignment.

23

Data.GenFiles.EditInfo.TextAreas.Texts.HorizontalLayout

String

The horizontal alignment.

24

Data.GenFiles.EditInfo.TextAreas.Texts.LineCount

Number

The number of lines in the text box.

25

Data.GenFiles.EditInfo.GoodsRects

Object

The product bounding box area.

26

Data.GenFiles.EditInfo.Font

Array[String]

The font type.

27

Data.GenFiles.ResultList

Array[Object]

A collection of translation results.

28

Data.GenFiles.ResultList.Language

String

The translated language.

29

Data.GenFiles.ResultList.FileUrl

String

The URL of the translated image.

Response example

{
  "Data": {
    "ImageUrl": "http://dashscope-a717.oss-cn-beijing.aliyuncs.com/.../7901aa74-translated.jpg",
    "UsageMap": { "ProcessedImageCount": 1 }
  },
  "RequestId": "1CEC4D94-905A-1ED1-A7B4-1BFEFFB3D850",
  "Message": "Success",
  "Code": "success",
  "Success": true
}

Supported language pairs

Image Translation-Standard Edition supports over 400 language pairs covering 156 languages, including through bridging. For example, Traditional Chinese (zh-tw) is translated via bridging through Simplified Chinese (zh). The supported language pairs are consistent with those for text translation. For a complete list of language pairs and their codes, see Language Mapping.

Error codes

Image Translation uses a unified system of named error codes. The following are common error codes for this service:

  • InvalidParameter: The image width or height exceeds 4,000 pixels, the file size is over 10 MB, or the format is not in the supported list (PNG, JPEG, JPG, BMP, or WebP).

  • DownstreamUnavailable: The image URL is inaccessible, or the service failed to download the image.

  • InputContentBlocked: The image content triggered the content moderation system.

For a complete list of error codes and troubleshooting suggestions, see Error Codes.

Limits

  • Call mode: Synchronous.

  • Input image: Width and height ≤ 4,000 pixels; file size ≤ 10 MB; formats: PNG, JPEG, JPG, BMP, or WebP. The image URL must be publicly accessible.

  • The source language and target language cannot be the same.

  • Translation quality may be reduced for curved text.

  • Billing: ¥0.015 per image. For details, see Billing.

  • The Standard Edition does not support automatic source language identification (you must explicitly pass the SourceLanguage parameter). If you need automatic identification, use the Pro Edition.