Image Translation (Image)

Prev Next

Available in Classic and VPC

Recognize (OCR) text in images in JPG, JPEG, PNG, and TIFF formats and provide translated text and translated images.

Note

Please note the following when using the API.

  • Small image sizes may result in poor translation results. We recommend using images that are at least 1280 px on the long axis.
  • Distorted image, cursive text, small sized text, and text with similar colors from the background may affect the quality of the image translation.

Request

This section describes the request format. The method and URI are as follows:

Method URI
POST /v1/translate

Request headers

For information about the headers common to all Papago Image Translation APIs, see Common Papago Image Translation headers.

Request body

You can include the following data in the body of your request:

Field Type Required Description
source String Required Language code of the source text (source)
  • auto (automatic language detection) | ko (Korean) | en (English) | ja (Japanese) | zh-CN (Chinese (Simplified)) | zh-TW (Chinese (Traditional)) | vi (Vietnamese) | th (Thai) | id (Indonesian) | fr (French) | es (Spanish) | ru (Russian)
target String Required Language code of the text to translate to (target)
  • ko (Korean) | en (English) | ja (Japanese) | zh-CN (Chinese (Simplified)) | zh-TW (Chinese (Traditional)) | vi (Vietnamese) | th (Thai) | id (Indonesian) | fr (French) | es (Spanish) | ru (Russian) | de (German) | it (Italian)
image JPG, JPEG, PNG, TIFF Required Original image file
Note

Even without specifying the source language (specified to auto), it automatically detects the language and provides a translation result. In this case, additional fees do not incur for detecting languages but only for the number of characters requested for translation.

Request example

The request example is as follows:

curl --location --request POST 'https://papago.apigw.ntruss.com/image-to-image/v1/translate' \
--header 'X-NCP-APIGW-API-KEY-ID: {Client ID issued when registering the app}' \
--header 'X-NCP-APIGW-API-KEY: {Client secret issued when registering the app}' \
--header 'Content-Type;' \
--form 'source="auto"' \
--form 'target="ko"' \
--form 'image=@"{image}"'

Response

This section describes the response format.

Response body

The response body includes the following data:

Field Type Required Description
data Object - Response result
data.sourceLang String - Source text language code
data.targetLang String - Translated text language code
data.sourceText String - Source text
data.targetText String - Translated text
data.blocks Array - Block-unit text recognition details
data.LB Object - Left bottom coordinate details
data.LB.x Integer - Left bottom coordinate x value
data.LB.y Integer - Left bottom coordinate y value
data.LT Object - Left top coordinate details
data.LT.x Integer - Left top coordinate x value
data.LT.y Integer - Left top coordinate y value
data.RB Object - Right bottom coordinate details
data.RB.x Integer - Right bottom coordinate x value
data.RB.y Integer - Right bottom coordinate y value
data.RT Object - Right top coordinate details
data.RT.x Integer - Right top coordinate x value
data.RT.y Integer - Right top coordinate y value
data.renderedImage String - Binary value of the translated image
  • Encoded in Base64 and returned in binary format

blocks

The following describes blocks.

Field Type Required Description
sourceLang String - Source text language code
sourceText String - Source text
targetText String - Translated text
lines Array - Line-unit text recognition details

lines

The following describes lines.

Field Type Required Description
LB Object - Left bottom coordinate details
LB.x Integer - Left bottom coordinate x value
LB.y Integer - Left bottom coordinate y value
LT Object - Left top coordinate details
LT.x Integer - Left top coordinate x value
LT.y Integer - Left top coordinate y value
RB Object - Right bottom coordinate details
RB.x Integer - Right bottom coordinate x value
RB.y Integer - Right bottom coordinate y value
RT Object - Right top coordinate details
RT.x Integer - Right top coordinate x value
RT.y Integer - Right top coordinate y value
words Array - Word-unit text recognition details

words

The following describes words.

Field Type Required Description
sourceText String - Source text
LB Object - Left bottom coordinate details
LB.x Integer - Left bottom coordinate x value
LB.y Integer - Left bottom coordinate y value
LT Object - Left top coordinate details
LT.x Integer - Left top coordinate x value
LT.y Integer - Left top coordinate y value
RB Object - Right bottom coordinate details
RB.x Integer - Right bottom coordinate x value
RB.y Integer - Right bottom coordinate y value
RT Object - Right top coordinate details
RT.x Integer - Right top coordinate x value
RT.y Integer - Right top coordinate y value

Response status codes

For information about the HTTP status codes common to all Papago Image Translation APIs, see Common Papago Image Translation response status codes.

Response example

The response example is as follows:

{
    "data": {
        "sourceLang": "en",
        "targetLang": "ko",
        "sourceText": "U.S. Department of State Office of Language Services Translating Division\nEnglish=> Foreign Lang, Set 1\nGeneral Category (231 words)\nPlease translate everything below:\n",
        "targetText": "U.S. Department of State, Language Services Translation Division\nEnglish => Foriegn language, set 1\nGeneral category (231 words)\nTranslate all of the following:\n",
        "blocks": [
            {
                "sourceLang": "en",
                "sourceText": "The two houses of Congress are much alike in their concern with local and special-interest legislation, their intricate legislative and parliamentary procedure, their tendency toward voting by blocks and interest groups in defiance of party ties. Yet the upper chamber has a character all its own.",
                "targetText": "The two chambers have very similar concerns regarding local and special interest legislation, complex legislative and parliamentary procedures, and a tendency to vote by blocs and interest groups ignoring party affiliations. However, both upper chambers have their own unique characteristics.",
                "lines": [
                    {
                        "LB": {
                            "x": 156,
                            "y": 238
                        },
                        "LT": {
                            "x": 156,
                            "y": 220
                        },
                        "RB": {
                            "x": 637,
                            "y": 238
                        },
                        "RT": {
                            "x": 637,
                            "y": 221
                        },
                        "words": [
                            {
                                "sourceText": "houses",
                                "LB": {
                                    "x": 213,
                                    "y": 235
                                },
                                "LT": {
                                    "x": 213,
                                    "y": 220
                                },
                                "RB": {
                                    "x": 261,
                                    "y": 235
                                },
                                "RT": {
                                    "x": 261,
                                    "y": 220
                                }
                            }
                        ]
                    }
                ]
            }
        ],
        "LB": {
            "x": 108,
            "y": 141
        },
        "LT": {
            "x": 108,
            "y": 91
        },
        "RB": {
            "x": 280,
            "y": 141
        },
        "RT": {
            "x": 280,
            "y": 91
        },
        "renderedImage": "{renderedImage}",
    }
}