通義萬相-影像編輯模型(wan2.5)支援多圖輸入(1-3張)和多圖輸出(1-4張),通過文本指令實現主體一致的單圖編輯、目標檢測與分割以及多圖融合等能力。
快速開始
前提條件
在調用前,先擷取與配置 API Key,再配置API Key到環境變數(準備下線,併入配置 API Key)。如需通過SDK進行調用,請安裝DashScope SDK。
範例程式碼
單圖輸入與多圖輸入的調用方式基本一致。
本樣本以多圖融合為例:在images數組中傳入2張映像,模型將根據文本提示詞輸出 1 張融合後的映像。
輸入提示詞:將圖1中的鬧鐘放置到圖2的餐桌的花瓶旁邊位置。
輸入映像1 | 輸入映像2 | 輸出映像 |
|
|
|
同步調用
請確保 DashScope Python SDK 版本不低於 1.25.2, DashScope Java SDK 版本不低於 2.22.2。
若版本過低,可能會觸發 “url error, please check url!” 等錯誤。請參考安裝或升級SDK進行更新。
Python
本樣本支援三種映像輸入方式:公網URL、Base64編碼、本地檔案路徑。
請求樣本
import base64
import mimetypes
from http import HTTPStatus
from urllib.parse import urlparse, unquote
from pathlib import PurePosixPath
import dashscope
import requests
from dashscope import ImageSynthesis
import os
# 以下為新加坡地區url,若使用北京地區的模型,需將url替換為:https://dashscope.aliyuncs.com/api/v1
dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'
# 若沒有配置環境變數,請用百鍊API Key將下行替換為:api_key="sk-xxx"
# 新加坡和北京地區的API Key不同。擷取API Key:https://www.alibabacloud.com/help/zh/model-studio/get-api-key
api_key = os.getenv("DASHSCOPE_API_KEY")
# --- 輸入圖片:使用 Base 64 編碼 ---
# base64編碼格式為 data:{MIME_type};base64,{base64_data}
def encode_file(file_path):
mime_type, _ = mimetypes.guess_type(file_path)
if not mime_type or not mime_type.startswith("image/"):
raise ValueError("不支援或無法識別的映像格式")
with open(file_path, "rb") as image_file:
encoded_string = base64.b64encode(image_file.read()).decode('utf-8')
return f"data:{mime_type};base64,{encoded_string}"
"""
映像輸入方式說明:
以下提供了三種圖片輸入方式,三選一即可
1. 使用公網URL - 適合已有公開可訪問的圖片
2. 使用本地檔案 - 適合本地開發測試
3. 使用Base64編碼 - 適合私人圖片或需要加密傳輸的情境
"""
# 【方式一】使用公網圖片 URL
image_url_1 = "https://img.alicdn.com/imgextra/i3/O1CN0157XGE51l6iL9441yX_!!6000000004770-49-tps-1104-1472.webp"
image_url_2 = "https://img.alicdn.com/imgextra/i3/O1CN01SfG4J41UYn9WNt4X1_!!6000000002530-49-tps-1696-960.webp"
# 【方式二】使用本地檔案(支援絕對路徑和相對路徑)
# 格式要求:file:// + 檔案路徑
# 樣本(絕對路徑):
# image_url_1 = "file://" + "/path/to/your/image_1.png" # Linux/macOS
# image_url_2 = "file://" + "C:/path/to/your/image_2.png" # Windows
# 樣本(相對路徑):
# image_url_1 = "file://" + "./image_1.png" # 以實際路徑為準
# image_url_2 = "file://" + "./image_2.png" # 以實際路徑為準
# 【方式三】使用Base64編碼的圖片
# image_url_1 = encode_file("./image_1.png") # 以實際路徑為準
# image_url_2 = encode_file("./image_2.png") # 以實際路徑為準
print('----sync call, please wait a moment----')
rsp = ImageSynthesis.call(api_key=api_key,
model="wan2.5-i2i-preview",
prompt="將圖1中的鬧鐘放置到圖2的餐桌的花瓶旁邊位置",
images=[image_url_1, image_url_2],
negative_prompt="",
n=1,
# size="1280*1280",
prompt_extend=True,
watermark=False,
seed=12345)
print('response: %s' % rsp)
if rsp.status_code == HTTPStatus.OK:
# 在目前的目錄下儲存圖片
for result in rsp.output.results:
file_name = PurePosixPath(unquote(urlparse(result.url).path)).parts[-1]
with open('./%s' % file_name, 'wb+') as f:
f.write(requests.get(result.url).content)
else:
print('sync_call Failed, status_code: %s, code: %s, message: %s' %
(rsp.status_code, rsp.code, rsp.message))響應樣本
url 有效期間24小時,請及時下載映像。
{
"status_code": 200,
"request_id": "8ad45834-4321-44ed-adf5-xxxxxx",
"code": null,
"message": "",
"output": {
"task_id": "3aff9ebd-35fc-4339-98a3-xxxxxx",
"task_status": "SUCCEEDED",
"results": [
{
"url": "https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/xxx.png?Expires=xxx",
"orig_prompt": "將圖1中的鬧鐘放置到圖2的餐桌的花瓶旁邊位置",
"actual_prompt": "將圖1中的藍色鬧鐘放置在圖2餐桌的花瓶右側,靠近桌布邊緣的位置,保持鬧鐘朝向鏡頭,與案頭平行,陰影自然投射於案頭。"
}
],
"submit_time": "2025-10-23 16:18:16.009",
"scheduled_time": "2025-10-23 16:18:16.040",
"end_time": "2025-10-23 16:19:09.591",
"task_metrics": {
"TOTAL": 1,
"FAILED": 0,
"SUCCEEDED": 1
}
},
"usage": {
"image_count": 1
}
}
Java
本樣本支援三種映像輸入方式:公網URL、Base64編碼、本地檔案路徑。
請求樣本
// Copyright (c) Alibaba, Inc. and its affiliates.
import com.alibaba.dashscope.aigc.imagesynthesis.ImageSynthesis;
import com.alibaba.dashscope.aigc.imagesynthesis.ImageSynthesisParam;
import com.alibaba.dashscope.aigc.imagesynthesis.ImageSynthesisResult;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.utils.Constants;
import com.alibaba.dashscope.utils.JsonUtils;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
public class Image2Image {
static {
// 以下為新加坡地區url,若使用北京地區的模型,需將url替換為:https://dashscope.aliyuncs.com/api/v1
Constants.baseHttpApiUrl = "https://dashscope-intl.aliyuncs.com/api/v1";
}
// 若沒有配置環境變數,請用百鍊API Key將下行替換為:apiKey="sk-xxx"
// 新加坡和北京地區的API Key不同。擷取API Key:https://www.alibabacloud.com/help/zh/model-studio/get-api-key
static String apiKey = System.getenv("DASHSCOPE_API_KEY");
/**
* 映像輸入方式說明:三選一即可
*
* 1. 使用公網URL - 適合已有公開可訪問的圖片
* 2. 使用本地檔案 - 適合本地開發測試
* 3. 使用Base64編碼 - 適合私人圖片或需要加密傳輸的情境
*/
//【方式一】公網URL
static String imageUrl_1 = "https://img.alicdn.com/imgextra/i3/O1CN0157XGE51l6iL9441yX_!!6000000004770-49-tps-1104-1472.webp";
static String imageUrl_2 = "https://img.alicdn.com/imgextra/i3/O1CN01SfG4J41UYn9WNt4X1_!!6000000002530-49-tps-1696-960.webp";
//【方式二】本地檔案路徑(file://+絕對路徑 or file:///+絕對路徑)
// static String imageUrl_1 = "file://" + "/your/path/to/image_1.png"; // Linux/macOS
// static String imageUrl_2 = "file:///" + "C:/your/path/to/image_2.png"; // Windows
//【方式三】Base64編碼
// static String imageUrl_1 = encodeFile("/your/path/to/image_1.png");
// static String imageUrl_2 = encodeFile("/your/path/to/image_2.png");
// 設定待編輯的圖片列表
static List<String> imageUrls = new ArrayList<>();
static {
imageUrls.add(imageUrl_1);
imageUrls.add(imageUrl_2);
}
public static void syncCall() {
// 設定parameters參數
Map<String, Object> parameters = new HashMap<>();
parameters.put("prompt_extend", true);
parameters.put("watermark", false);
parameters.put("seed", "12345");
ImageSynthesisParam param =
ImageSynthesisParam.builder()
.apiKey(apiKey)
.model("wan2.5-i2i-preview")
.prompt("將圖1中的鬧鐘放置到圖2的餐桌的花瓶旁邊位置")
.images(imageUrls)
.n(1)
//.size("1280*1280")
.negativePrompt("")
.parameters(parameters)
.build();
ImageSynthesis imageSynthesis = new ImageSynthesis();
ImageSynthesisResult result = null;
try {
System.out.println("---sync call, please wait a moment----");
result = imageSynthesis.call(param);
} catch (ApiException | NoApiKeyException e){
throw new RuntimeException(e.getMessage());
}
System.out.println(JsonUtils.toJson(result));
}
/**
* 將檔案編碼為Base64字串
* @param filePath 檔案路徑
* @return Base64字串,格式為 data:{MIME_type};base64,{base64_data}
*/
public static String encodeFile(String filePath) {
Path path = Paths.get(filePath);
if (!Files.exists(path)) {
throw new IllegalArgumentException("檔案不存在: " + filePath);
}
// 檢測MIME類型
String mimeType = null;
try {
mimeType = Files.probeContentType(path);
} catch (IOException e) {
throw new IllegalArgumentException("無法檢測檔案類型: " + filePath);
}
if (mimeType == null || !mimeType.startsWith("image/")) {
throw new IllegalArgumentException("不支援或無法識別的映像格式");
}
// 讀取檔案內容並編碼
byte[] fileBytes = null;
try{
fileBytes = Files.readAllBytes(path);
} catch (IOException e) {
throw new IllegalArgumentException("無法讀取檔案內容: " + filePath);
}
String encodedString = Base64.getEncoder().encodeToString(fileBytes);
return "data:" + mimeType + ";base64," + encodedString;
}
public static void main(String[] args) {
syncCall();
}
}響應樣本
url 有效期間24小時,請及時下載映像。
{
"request_id": "d362685b-757f-4eac-bab5-xxxxxx",
"output": {
"task_id": "bfa7fc39-3d87-4fa7-b1e6-xxxxxx",
"task_status": "SUCCEEDED",
"results": [
{
"orig_prompt": "將圖1中的鬧鐘放置到圖2的餐桌的花瓶旁邊位置",
"actual_prompt": "將圖1中的藍色鬧鐘放置在圖2餐桌的花瓶右側,靠近桌布邊緣的位置,保持鬧鐘正面朝向鏡頭,與花瓶平行擺放。",
"url": "https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/xxx.png?Expires=xxx"
}
],
"task_metrics": {
"TOTAL": 1,
"SUCCEEDED": 1,
"FAILED": 0
}
},
"usage": {
"image_count": 1
}
}非同步呼叫
請確保 DashScope Python SDK 版本不低於 1.25.2, DashScope Java SDK 版本不低於 2.22.2。
若版本過低,可能會觸發 “url error, please check url!” 等錯誤。請參考安裝或升級SDK進行更新。
Python
本樣本使用公網URL方式傳入圖片。
請求樣本
import os
from http import HTTPStatus
from urllib.parse import urlparse, unquote
from pathlib import PurePosixPath
import dashscope
import requests
from dashscope import ImageSynthesis
# 以下為新加坡地區url,若使用北京地區的模型,需將url替換為:https://dashscope.aliyuncs.com/api/v1
dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'
# 若沒有配置環境變數,請用百鍊API Key將下行替換為:api_key="sk-xxx"
# 新加坡和北京地區的API Key不同。擷取API Key:https://www.alibabacloud.com/help/zh/model-studio/get-api-key
api_key = os.getenv("DASHSCOPE_API_KEY")
# 使用公網圖片 URL
image_url_1 = "https://img.alicdn.com/imgextra/i3/O1CN0157XGE51l6iL9441yX_!!6000000004770-49-tps-1104-1472.webp"
image_url_2 = "https://img.alicdn.com/imgextra/i3/O1CN01SfG4J41UYn9WNt4X1_!!6000000002530-49-tps-1696-960.webp"
def async_call():
print('----create task----')
task_info = create_async_task()
print('----wait task----')
wait_async_task(task_info)
# 建立非同步任務
def create_async_task():
rsp = ImageSynthesis.async_call(api_key=api_key,
model="wan2.5-i2i-preview",
prompt="將圖1中的鬧鐘放置到圖2的餐桌的花瓶旁邊位置",
images=[image_url_1, image_url_2],
negative_prompt="",
n=1,
# size="1280*1280",
prompt_extend=True,
watermark=False,
seed=12345)
print(rsp)
if rsp.status_code == HTTPStatus.OK:
print(rsp.output)
else:
print('Failed, status_code: %s, code: %s, message: %s' %
(rsp.status_code, rsp.code, rsp.message))
return rsp
# 等待非同步任務結束
def wait_async_task(task):
rsp = ImageSynthesis.wait(task=task, api_key=api_key)
print(rsp)
if rsp.status_code == HTTPStatus.OK:
print(rsp.output)
# save file to current directory
for result in rsp.output.results:
file_name = PurePosixPath(unquote(urlparse(result.url).path)).parts[-1]
with open('./%s' % file_name, 'wb+') as f:
f.write(requests.get(result.url).content)
else:
print('Failed, status_code: %s, code: %s, message: %s' %
(rsp.status_code, rsp.code, rsp.message))
# 擷取非同步任務資訊
def fetch_task_status(task):
status = ImageSynthesis.fetch(task=task, api_key=api_key)
print(status)
if status.status_code == HTTPStatus.OK:
print(status.output.task_status)
else:
print('Failed, status_code: %s, code: %s, message: %s' %
(status.status_code, status.code, status.message))
# 取消非同步任務,只有處於PENDING狀態的任務才可以取消
def cancel_task(task):
rsp = ImageSynthesis.cancel(task=task, api_key=api_key)
print(rsp)
if rsp.status_code == HTTPStatus.OK:
print(rsp.output.task_status)
else:
print('Failed, status_code: %s, code: %s, message: %s' %
(rsp.status_code, rsp.code, rsp.message))
if __name__ == '__main__':
async_call()
響應樣本
1、建立任務的響應樣本
{
"status_code": 200,
"request_id": "31b04171-011c-96bd-ac00-f0383b669cc7",
"code": "",
"message": "",
"output": {
"task_id": "4f90cf14-a34e-4eae-xxxxxxxx",
"task_status": "PENDING",
"results": []
},
"usage": null
}2、查詢任務結果的響應樣本
url 有效期間24小時,請及時下載映像。
{
"status_code": 200,
"request_id": "8ad45834-4321-44ed-adf5-xxxxxx",
"code": null,
"message": "",
"output": {
"task_id": "3aff9ebd-35fc-4339-98a3-xxxxxx",
"task_status": "SUCCEEDED",
"results": [
{
"url": "https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/xxx.png?Expires=xxx",
"orig_prompt": "將圖1中的鬧鐘放置到圖2的餐桌的花瓶旁邊位置",
"actual_prompt": "將圖1中的藍色鬧鐘放置在圖2餐桌的花瓶右側,靠近桌布邊緣的位置,保持鬧鐘朝向鏡頭,與案頭平行,陰影自然投射於案頭。"
}
],
"submit_time": "2025-10-23 16:18:16.009",
"scheduled_time": "2025-10-23 16:18:16.040",
"end_time": "2025-10-23 16:19:09.591",
"task_metrics": {
"TOTAL": 1,
"FAILED": 0,
"SUCCEEDED": 1
}
},
"usage": {
"image_count": 1
}
}
Java
本樣本預設使用公網URL方式傳入圖片。
請求樣本
// Copyright (c) Alibaba, Inc. and its affiliates.
import com.alibaba.dashscope.aigc.imagesynthesis.ImageSynthesis;
import com.alibaba.dashscope.aigc.imagesynthesis.ImageSynthesisListResult;
import com.alibaba.dashscope.aigc.imagesynthesis.ImageSynthesisParam;
import com.alibaba.dashscope.aigc.imagesynthesis.ImageSynthesisResult;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.task.AsyncTaskListParam;
import com.alibaba.dashscope.utils.Constants;
import com.alibaba.dashscope.utils.JsonUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Image2Image {
static {
// 以下為新加坡地區url,若使用北京地區的模型,需將url替換為:https://dashscope.aliyuncs.com/api/v1
Constants.baseHttpApiUrl = "https://dashscope-intl.aliyuncs.com/api/v1";
}
// 若沒有配置環境變數,請用百鍊API Key將下行替換為:apiKey="sk-xxx"
// 新加坡和北京地區的API Key不同。擷取API Key:https://www.alibabacloud.com/help/zh/model-studio/get-api-key
static String apiKey = System.getenv("DASHSCOPE_API_KEY");
//公網URL
static String imageUrl_1 = "https://img.alicdn.com/imgextra/i3/O1CN0157XGE51l6iL9441yX_!!6000000004770-49-tps-1104-1472.webp";
static String imageUrl_2 = "https://img.alicdn.com/imgextra/i3/O1CN01SfG4J41UYn9WNt4X1_!!6000000002530-49-tps-1696-960.webp";
// 設定待編輯的圖片列表
static List<String> imageUrls = new ArrayList<>();
static {
imageUrls.add(imageUrl_1);
imageUrls.add(imageUrl_2);
}
public static void asyncCall() {
// 設定parameters參數
Map<String, Object> parameters = new HashMap<>();
parameters.put("prompt_extend", true);
parameters.put("watermark", false);
parameters.put("seed", "12345");
ImageSynthesisParam param =
ImageSynthesisParam.builder()
.apiKey(apiKey)
.model("wan2.5-i2i-preview")
.prompt("將圖1中的鬧鐘放置到圖2的餐桌的花瓶旁邊位置")
.images(imageUrls)
.n(1)
//.size("1280*1280")
.negativePrompt("")
.parameters(parameters)
.build();
ImageSynthesis imageSynthesis = new ImageSynthesis();
ImageSynthesisResult result = null;
try {
System.out.println("---async call, please wait a moment----");
result = imageSynthesis.asyncCall(param);
} catch (ApiException | NoApiKeyException e){
throw new RuntimeException(e.getMessage());
}
System.out.println(JsonUtils.toJson(result));
String taskId = result.getOutput().getTaskId();
System.out.println("taskId=" + taskId);
try {
result = imageSynthesis.wait(taskId, apiKey);
} catch (ApiException | NoApiKeyException e){
throw new RuntimeException(e.getMessage());
}
System.out.println(JsonUtils.toJson(result));
System.out.println(JsonUtils.toJson(result.getOutput()));
}
public static void listTask() throws ApiException, NoApiKeyException {
ImageSynthesis is = new ImageSynthesis();
AsyncTaskListParam param = AsyncTaskListParam.builder().build();
param.setApiKey(apiKey);
ImageSynthesisListResult result = is.list(param);
System.out.println(result);
}
public void fetchTask(String taskId) throws ApiException, NoApiKeyException {
ImageSynthesis is = new ImageSynthesis();
// 如果已設定 DASHSCOPE_API_KEY 為環境變數,apiKey 可為空白。
ImageSynthesisResult result = is.fetch(taskId, apiKey);
System.out.println(result.getOutput());
System.out.println(result.getUsage());
}
public static void main(String[] args) {
asyncCall();
}
}響應樣本
1、建立任務的響應樣本
{
"request_id": "5dbf9dc5-4f4c-9605-85ea-542f97709ba8",
"output": {
"task_id": "7277e20e-aa01-4709-xxxxxxxx",
"task_status": "PENDING"
}
}2、查詢任務結果的響應樣本
url 有效期間24小時,請及時下載圖片。
{
"request_id": "d362685b-757f-4eac-bab5-xxxxxx",
"output": {
"task_id": "bfa7fc39-3d87-4fa7-b1e6-xxxxxx",
"task_status": "SUCCEEDED",
"results": [
{
"orig_prompt": "將圖1中的鬧鐘放置到圖2的餐桌的花瓶旁邊位置",
"actual_prompt": "將圖1中的藍色鬧鐘放置在圖2餐桌的花瓶右側,靠近桌布邊緣的位置,保持鬧鐘正面朝向鏡頭,與花瓶平行擺放。",
"url": "https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/xxx.png?Expires=xxx"
}
],
"task_metrics": {
"TOTAL": 1,
"SUCCEEDED": 1,
"FAILED": 0
}
},
"usage": {
"image_count": 1
}
}curl
本樣本包含建立任務和查詢結果兩個步驟。
非同步呼叫必須設定 Header 參數
X-DashScope-Async為enable。非同步任務的
task_id查詢有效期間為 24 小時,到期後任務狀態將變為UNKNOWN。
步驟1:發起建立工作要求
該請求會返回一個任務ID(task_id)。
請求樣本
curl --location 'https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/image2image/image-synthesis' \
-H 'X-DashScope-Async: enable' \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "wan2.5-i2i-preview",
"input": {
"prompt": "將圖1中的鬧鐘放置到圖2的餐桌的花瓶旁邊位置",
"images": [
"https://img.alicdn.com/imgextra/i3/O1CN0157XGE51l6iL9441yX_!!6000000004770-49-tps-1104-1472.webp",
"https://img.alicdn.com/imgextra/i3/O1CN01SfG4J41UYn9WNt4X1_!!6000000002530-49-tps-1696-960.webp"
]
},
"parameters": {
"n": 1
}
}'響應樣本
{
"output": {
"task_status": "PENDING",
"task_id": "0385dc79-5ff8-4d82-bcb6-xxxxxx"
},
"request_id": "4909100c-7b5a-9f92-bfe5-xxxxxx"
}步驟2:根據任務ID查詢結果
使用上一步擷取的 task_id,通過介面輪詢任務狀態,直到 task_status 變為 SUCCEEDED 或 FAILED。
請求樣本
請將86ecf553-d340-4e21-xxxxxxxxx替換為真實的task_id。
新加坡和北京地區的API Key不同。擷取與配置 API Key。
以下為新加坡地區base_url,若使用北京地區的模型,需將base_url替換為https://dashscope.aliyuncs.com/api/v1/tasks/86ecf553-d340-4e21-xxxxxxxxx
curl -X GET https://dashscope-intl.aliyuncs.com/api/v1/tasks/86ecf553-d340-4e21-xxxxxxxxx \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"響應樣本
映像URL有效期間為24小時,請及時下載映像。
{
"request_id": "d1f2a1be-9c58-48af-b43f-xxxxxx",
"output": {
"task_id": "7f4836cd-1c47-41b3-b3a4-xxxxxx",
"task_status": "SUCCEEDED",
"submit_time": "2025-09-23 22:14:10.800",
"scheduled_time": "2025-09-23 22:14:10.825",
"end_time": "2025-09-23 22:15:23.456",
"results": [
{
"orig_prompt": "將圖1中的鬧鐘放置到圖2的餐桌的花瓶旁邊位置",
"url": "https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/xxx.png?Expires=xxx"
}
],
"task_metrics": {
"TOTAL": 1,
"FAILED": 0,
"SUCCEEDED": 1
}
},
"usage": {
"image_count": 1
}
}支援的模型
模型列表和價格請參見通義萬相通用影像編輯2.5。
輸入說明
輸入映像(images)
images是一個數組,支援傳入 1~3 張 圖片進行編輯或融合。輸入圖片必須滿足以下要求:
圖片格式:支援 JPEG、JPG、PNG (不支援透明通道)、BMP、WEBP。
圖片解析度:映像的寬高範圍均為[384, 5000]像素。
檔案大小:單張圖片檔案大小不得超過 10MB。
// 以下樣本僅展示 images 欄位結構,輸入包含 2 張映像
{
"images": [
"https://img.alicdn.com/imgextra/i4/O1CN01TlDlJe1LR9zso3xAC_!!6000000001295-2-tps-1104-1472.png",
"https://img.alicdn.com/imgextra/i4/O1CN01M9azZ41YdblclkU6Z_!!6000000003082-2-tps-1696-960.png"
]
}映像輸入順序
多圖輸入時,按照數組順序定義映像順序。因此,提示詞引用的映像編號需要與映像數組中的順序一一對應,例如:數組中的第一張圖片為“圖1”,第二張為“圖2”,或者使用標記形式如“[圖1]”、“[圖2]”。
輸入映像 | 輸出映像 | ||
圖1 |
圖2 |
提示詞:把圖1移動到圖2上 |
提示詞:把圖2移動到圖1上 |
映像傳入方式
本模型支援通過以下三種方式傳入映像:
選擇性參數
本模型還提供一些 選擇性參數 用於調整映像產生效果。其中重要參數包括:
size:設定輸出映像的解析度,格式為寬*高,單位為像素。預設值為1280*1280。映像解析度總像素在 [768*768, 1280*1280] 之間,且寬高比範圍為 [1:4, 4:1]。若未指定
size,系統將預設產生 1280*1280 像素的映像,並近似保持輸入映像的寬高比:單圖輸入:寬高比與輸入映像一致;
多圖輸入:寬高比與最後一張輸入映像一致。
n:設定輸出映像的數量。取值範圍為1~4張,預設為4。測試階段建議設定為1。negative_prompt:反向提示詞,描述不希望在畫面中出現的內容,如“模糊”、“多餘的手指”等。僅用於輔助最佳化產生品質。watermark:是否添加浮水印標識,浮水印位於圖片右下角,文案固定為“AI產生”。預設為false,表示不添加浮水印。seed:隨機數種子。取值範圍是[0, 2147483647]。如果不提供,則演算法自動產生一個隨機數作為種子。如果希望產生內容保持相對穩定,可使用相同的seed參數值。注意:由於模型產生具有機率性,相同 seed也不能保證每次產生結果完全一致。
輸出說明
圖片格式:PNG。
映像張數:1~4張。
映像解析度:可通過輸入參數
size指定解析度;若未指定,請參見size參數說明。所有輸出映像將採用相同的解析度。
效果展示
影像編輯wan2.5模型暫不支援組圖產生。
多圖融合
輸入映像 | 輸出映像 |
|
把圖2的星空畫作遷移到圖1的手機殼上 |
|
以[圖1]的字型文字造型“Wan2.5”為唯一依據,保持筆畫粗細與曲線不變;將[圖2]的層疊紙材質精準遷移到文字。 |
|
使用兩張參考圖進行定向重繪:以[圖2]為包包的造型與結構參考,以[圖1]中的鸚鵡羽毛為顏色與紋理參考,將鸚鵡羽毛的色彩與紋理質感精準遷移到[圖2]的包面材質上。 |
|
融合[圖1][圖2]製作太空主題海報:讓[圖2]的玩偶漂浮宇宙中,雙手捧起懸浮的[圖1]logo;logo為發光立體紫色透明材質,具折射與體積光,光暈映照玩偶與周圍微塵。背景深空星雲與星塵軌跡,右上加入遠景環形空間站與燈帶細節,主體置中突出、留白均衡。標題置頂“通義萬相發布”:幾何無襯線超黑體、字距略寬、純白主色+紫藍外光暈+細銀描邊;副標題其下“Unleash Your Creativity”:輕細無襯線、淺紫至青藍漸層、微內陰影與柔光。整體紫藍調,高解析度,不加其他文字。 |
|
以[圖1]名片設計稿的構圖與磨砂玻璃質感為模板,為[圖2]人物產生豎版工作卡。圓角半透明卡面,柔和高光與淺投影;人物胸像置於中上地區;左下排版姓名/職位/公司/電話,極簡無襯線字型,留白均衡。右上方放置[圖1]人物的可愛3D卡通形象,打破邊界半浮出卡片並投下輕影,形成層次與視覺焦點。整體明亮自然光、真實材質細節,不添加多餘圖案與元素。 |
映像理解
目標檢測與定位
檢測映像中指定的目標,輸出一張帶有檢測框和標籤的映像。
輸入映像 | 輸出映像 |
|
檢測圖中的向日葵和南瓜,繪製檢測框並標上標籤 |
執行個體分割
模型將為映像中每個獨立對象產生一個專屬顏色地區,展示其完整輪廓。例如,輸出映像的紫色地區代表被分割出的耳機執行個體。
輸入映像 | 輸出映像 |
|
分割出圖中的耳機 |
主體特徵保持
輸入映像 | 輸出映像 |
|
Generate a highly detailed photo of a girl cosplaying this illustration, at Comiket. It must be a real person cosplaying. Exactly replicate the same pose, body posture, hand gestures, facial expression, and camera framing as in the original illustration. Keep the same angle, perspective, and composition, without any deviation. |
|
在辦公室情境中產生3個同樣的該照片中的人物,其中一個坐在辦公桌前辦公,另一個站著在喝咖啡,第三個靠在辦公桌前在看書,這3個人是同一個人,都是照片中的那個人物。 |
|
為這張照片產生一個4宮格套圖,第一張讓這個女孩身體正面面向鏡頭,第二張讓她舉起右手撩頭髮,第三組讓她向螢幕前的觀眾熱情地揮手打招呼,第四張她的表情要閉上眼微笑 |
修改及放大
功能 | 輸入映像 | 輸出映像 |
修改元素 |
|
將花卉連衣裙換成一件複古風格的蕾絲長裙,領口和袖口有精緻的刺繡細節。 |
修改光線 |
|
在海星表面添加小而閃爍的高光,使其在夕陽背景下呈現出發光的效果。 |
放大主體元素 |
|
把圖中的牛放大 |
放大映像細節 |
|
放大並展現鸚鵡棲息的樹枝 |
提取元素
輸入映像 | 輸出映像 |
|
將圖中人物身穿的服飾單品都提取出來,擺放在白底背景中,整齊地排列。 |
線稿生圖
輸入映像 | 輸出映像 |
|
Generate a new real image based on this sketch, a charming Mediterranean village scene with rustic stone buildings featuring terracotta roofs, wooden shutters, and balconies adorned with hanging laundry. The foreground is filled with lush greenery, including climbing vines and blooming flowers, creating a vibrant and lively atmosphere. The architecture showcases intricate details like arched doorways and patterned stonework, evoking a sense of history and warmth], [a bright, sunny day with clear blue skies, casting soft shadows across the cobblestone streets and enhancing the warm tones of the buildings. In the background, rolling hills and distant mountains provide a picturesque setting, adding depth and serenity to the scene. |
文字產生
輸入映像 | 輸出映像 |
|
在圖片的左上方添加大號圓角字型的白色標題文字:“微距攝影”,標題文字下面有淡綠色小號副標題:“勤勞就有收穫”。 |
去浮水印
輸入映像 | 輸出映像 |
|
去除左上方所有文字 |
擴圖
輸入映像 | 輸出映像 |
|
向外擴圖,產生這張圖的遠景照片 |
計費與限流
API參考
輸入和輸出參數請參見通義萬相-通用影像編輯2.5 API參考。
常見問題
Q:之前使用通用影像編輯 2.1,現在切換到 wan2.5 模型,SDK調用方式需要調整嗎?
A:需要調整。兩個版本的參數設計不同:











































