将图片上的文字从一种语言翻译成另一种语言,并输出一张尽可能忠于原图的新图片。
接口说明
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
调试
授权信息
|
操作 |
访问级别 |
资源类型 |
条件关键字 |
关联操作 |
|
alimt:TranslateImage |
none |
*全部资源
|
无 | 无 |
请求参数
|
名称 |
类型 |
必填 |
描述 |
示例值 |
| ImageUrl |
string |
否 |
原图 URL,跟 Base64 不能同时为空,优先取 Base64。 |
https://example.com/example.jpg |
| ImageBase64 |
string |
否 |
原图 Base64,跟 URL 不能同时为空,优先取 Base64。 |
/9j/4...H/9k= |
| SourceLanguage |
string |
否 |
源语种,支持的语种参考,必填(请忽略表格中“是否必填”中的“否”) |
zh |
| TargetLanguage |
string |
否 |
目标语种,支持的语种参考,必填(请忽略表格中“是否必填”中的“否”) |
en |
| Field |
string |
否 |
翻译领域, 可选值如下。
默认及未识别领域均按通用图片翻译处理。 |
general |
| Ext |
string |
否 |
扩展信息, JSON String 格式,里面可以包含的字段如下。
|
{"needEditorData": "false", "ignoreEntityRecognize": "true"} |
返回参数
|
名称 |
类型 |
描述 |
示例值 |
|
object |
结果 |
||
| RequestId |
string |
请求标识 |
D774D33D-F1CB-5A2C-A787-E0A2179239CE |
| Code |
integer |
请求结果状态码 |
200 |
| Message |
string |
请求错误信息 |
Error Message |
| Data |
object |
图片翻译结果结构体 |
|
| InPaintingUrl |
string |
图片译后编辑器背景图 |
https://example.com/example.jpg |
| TemplateJson |
string |
图片译后编辑器模版数据 |
Editor Template Json String |
| FinalImageUrl |
string |
最终翻译结果图片 URL |
https://example.com/example.jpg |
示例
正常返回示例
JSON格式
{
"RequestId": "D774D33D-F1CB-5A2C-A787-E0A2179239CE",
"Code": 200,
"Message": "Error Message",
"Data": {
"InPaintingUrl": "https://example.com/example.jpg",
"TemplateJson": "Editor Template Json String",
"FinalImageUrl": "https://example.com/example.jpg"
}
}
错误码
|
HTTP status code |
错误码 |
错误信息 |
描述 |
|---|---|---|---|
| 400 | Parameter.SourceLangError | Source languages are not supported. | 源语种不支持。 |
| 400 | Parameter.TargetLangError | Target languages are not supported. | 目标语种不支持。 |
| 401 | System.subNotPermission | The sub-account is not authorized to perform the operation. | |
| 401 | System.AccountNotActivated | The account has not activated the service. | |
| 500 | System.unknownError | An unknown error occurred. | 未知错误 |
| 500 | ImageTranslate.TranslationError | Image translation error. | 图片翻译错误 |
| 500 | ImageTranslate.FusionError | Image fusion error. | 合图错误 |
| 500 | ImageTranslate.EraseError | Image erasing error. | 擦图错误 |
| 500 | ImageTranslate.TextTranslationError | Text translation error. | 文本翻译错误 |
| 500 | ImageTranslate.TextToParagraphError | Text to paragraph error. | 段落合并错误 |
| 406 | System.ParameterError | Some required parameters are missing. | |
| 406 | Parameter.ImageUrlError | Failed to obtain the image from the URL. | 从URL下载图片失败 |
| 406 | Parameter.ImageSizeError | Image size should be within 15px to 8192px. | 图片尺寸超出限制,需在15px到8192px之间 |
| 406 | Parameter.ImageFormatError | The image format is not supported. | 图片格式不支持 |
| 406 | Parameter.ImageFileSizeError | The image file size should be within 10 MB. | 图片大小超出限制,需在10MB以内 |
访问错误中心查看更多错误码。
变更历史
更多信息,参考变更详情。