请先获取 API Key 并设置为环境变量。
扩图模式与优先级
参数存在优先级关系:当同时设置多个扩图模式的参数时,仅高优先级的参数生效。旋转参数 angle 不受优先级影响,可与任意扩图模式叠加使用。
| 功能 | 参数 | 说明 |
|---|---|---|
| 旋转 | angle | 先旋转,后扩展。可与下方任意扩图模式同时使用。 |
| 扩图优先级 1 | output_ratio | 按宽高比扩展画面。 |
| 扩图优先级 2 | x_scale、y_scale | 按比例扩展画面。 |
| 扩图优先级 3 | left_offset、right_offset、top_offset、bottom_offset | 在指定方向添加像素扩展画面。 |
参数设置建议
- 仅按宽高比扩图:设置
output_ratio为非空值(如"4:3")。 - 仅按比例扩图:设置
x_scale和y_scale,至少一个大于 1.0。 - 仅在指定方向添加像素扩图:设置
left_offset、right_offset、top_offset、bottom_offset,至少一个大于 0。 - 仅旋转图像:设置
angle为 [1, 359] 之间的值。建议避免设置为 90、180、270 度。 - 先旋转再扩图:设置
angle的同时,搭配上述任一扩图模式的参数。
参数组合示例
查看组合示例
查看组合示例
| 参数设置 | 生效参数 | 说明 |
|---|---|---|
output_ratio="4:3", x_scale=2.0 | output_ratio | output_ratio 优先级高于 x_scale。 |
x_scale=2.0, left_offset=100 | x_scale | x_scale 优先级高于 left_offset。 |
angle=90, x_scale=2.0 | angle + x_scale | 旋转与扩图叠加,两者均生效。 |
angle=90, output_ratio="4:3", x_scale=2.0, left_offset=100 | angle + output_ratio | 旋转与最高优先级扩图模式生效。 |
错误码
| HTTP 状态码 | 错误码 | 错误信息 | 说明 |
|---|---|---|---|
| 400 | InvalidParameter.JsonPhrase | input json error | 输入 JSON 格式错误。 |
| 400 | InvalidParameter.FileDownload | oss download error | 输入图像下载失败,请检查 URL 是否有效。 |
| 400 | InvalidParameter.ImageFormat | read image error | 读取图像失败,请检查图像格式。 |
| 400 | InvalidParameter.ImageContent | The image content does not comply with green network verification | 图像内容不合规。 |
| 400 | InvalidParameter | the parameters must conform to the specification: xxx | 输入参数值超出范围。 |
| 400 | InvalidParameter.DataInspection | The image size is not supported for the data inspection. | 输出图像尺寸超限(大于 10 MB)。 |
| 500 | InternalError.Algo | algorithm process error | 算法处理错误。 |
| 500 | InternalError.FileUpload | oss upload error | 文件上传失败。 |
FAQ
创建任务接口响应成功,但没有返回图像 URL?
创建任务接口响应成功,但没有返回图像 URL?
创建任务接口只返回
task_id 和 task_status。请使用查询扩图结果接口,通过 task_id 轮询获取生成结果。设置 output_ratio 后,为什么模型没有根据 x_scale 或 y_scale 自动计算另一个方向的比例?
设置 output_ratio 后,为什么模型没有根据 x_scale 或 y_scale 自动计算另一个方向的比例?
三种扩图方式(宽高比、比例缩放、方向偏移)是互斥的,存在优先级关系。
output_ratio 优先级最高,设置后 x_scale/y_scale 和 *_offset 参数不生效。如需按比例扩图,请不要设置 output_ratio。鉴权
string
header
必填
千问云 API Key。详见获取 API Key。
Header 参数
enum<string>
默认值"enable"
必填
开启异步处理,必须设为 enable。HTTP 调用仅支持异步方式,不设置此 Header 会返回错误。
enable

