Skip to main content

Image editing - Wan2.5 to 2.7

Edit images with text instructions using Wan models. Supports multi-image input/output, image fusion, subject preservation, and object detection.

Getting started

Generate an edited image from two input images and a text prompt with wan2.7-image-pro.
Prompt: Spray the graffiti from image 2 onto the car in image 1

Input image 1

Input image 2

Output image (wan2.7-image-pro)

umbrella

input2

1774509357_902b1408-2026-03-30-16-12-31

Before making the call, first obtain and configure an API Key, and then configure the API Key in environment variables. To make calls through an SDK, install the DashScope SDK.
  • Synchronous call
  • Asynchronous call
Please ensure that the DashScope Python SDK version is no earlier than2.1.0, and that the DashScope Java SDK version is no earlier than2.22.13.
  • Python
  • Java
  • curl

Sample request

import os
import base64
import mimetypes
import requests
import dashscope

# 以下为华北2(北京)地域的配置,调用时请将{WorkspaceId}替换为真实的业务空间ID,各地域的region取值不同。
# 若没有配置环境变量,请用百炼API Key将下行替换为:api_key="sk-xxx"
# 各地域的API Key不同。获取API Key:https://help.aliyun.com/zh/model-studio/get-api-key
client = dashscope.Client(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    workspace="{WorkspaceId}",
    region="cn-beijing",
)

# --- Base64编码函数 ---
# 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_1 = "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20251229/pjeqdf/car.webp"
image_2 = "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20251229/xsunlm/paint.webp"

# 【方式二】使用本地文件(支持绝对路径和相对路径)
# image_1 = "file:///path/to/your/car.png"
# image_2 = "file:///path/to/your/paint.png"

# 【方式三】使用Base64编码的图片
# image_1 = encode_file("/path/to/your/car.png")
# image_2 = encode_file("/path/to/your/paint.png")

print("----sync call, please wait a moment----")
# generate 为一步式调用(提交+等待),直接返回已完成的任务结果
job = client.images.generate(
    model="wan2.7-image-pro",
    prompt="把图2的涂鸦喷绘在图1的汽车上",
    # 参考图列表,支持本地文件 如 "file:///path/to/your/car.png"
    image_urls=[image_1, image_2],
    watermark=False,
    n=1,
    size="2K",  # wan2.7-image-pro仅文生图场景支持4K分辨率,图像编辑和组图生成支持最高2K分辨率
)

# 提取结果图片URL并保存到本地
for i, image_url in enumerate(job.image_urls):
    file_name = f"output_{i}.png"
    # 结果URL有效期为24小时,请及时下载
    with open(file_name, "wb") as f:
        f.write(requests.get(image_url).content)
    print(f"Image saved to {file_name}")

Sample response

The URL is valid for 24 hours. Download the image promptly.
{
    "request_id": "81d868c6-6ce1-92d8-a90d-d2ee71xxxxxx",
    "task_id": "127ec645-118f-4884-955d-0eba8dxxxxxx",
    "status": "SUCCEEDED",
    "results": [
        {
            "url": "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/xxxxxx.png?Expires=xxxxxx"
        }
    ],
    "task_metrics": {
        "TOTAL": 1,
        "SUCCEEDED": 1,
        "FAILED": 0
    },
    "usage": {
        "image_count": 1,
        "size": "2985*1405"
    }
}
wan2.5-i2i-preview uses a different API endpoint and parameter passing method. Its calling examples are as follows:
  • Synchronous call
  • Asynchronous call
Please ensure that the DashScope Python SDK version is no earlier than2.0.1, and that the DashScope Java SDK version is no earlier than2.22.2.If the version is too old, errors such as "url error, please check url!" may occur. Refer to Install or upgrade the SDK to update it.
  • Python
  • Java
This example supports three image input methods: public URL, Base64 encoding, and local file path.
Sample request
import base64
import mimetypes
from urllib.parse import urlparse, unquote
from pathlib import PurePosixPath
import dashscope
import requests
import os

# 以下为华北2(北京)地域的配置。请将 {WorkspaceId} 替换为您的百炼业务空间ID,各地域的region取值不同。
# 若没有配置环境变量,请用百炼API Key将下行替换为:api_key="sk-xxx"
# 新加坡和北京地域的API Key不同。获取API Key:https://help.aliyun.com/zh/model-studio/get-api-key
client = dashscope.Client(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    workspace="{WorkspaceId}",
    region="cn-beijing",
)

# --- 输入图片:使用 Base64 编码 ---
# 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_1.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----')
# generate 为一步式调用(提交+等待),直接返回已完成的任务结果
job = client.images.generate(model="wan2.5-i2i-preview",
                             prompt="将图1中的闹钟放置到图2的餐桌的花瓶旁边位置",
                             extra_input={'images': [image_url_1, image_url_2]},
                             negative_prompt="",
                             n=1,
                             # size="1280*1280",
                             prompt_extend=True,
                             watermark=False,
                             seed=12345)
print('response: %s' % job)
# 在当前目录下保存图片
for result in job.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)
Response example
The URL is valid for 24 hours. Download the image promptly.
{
    "request_id": "8ad45834-4321-44ed-adf5-xxxxxx",
    "task_id": "3aff9ebd-35fc-4339-98a3-xxxxxx",
    "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餐桌的花瓶右侧,靠近桌布边缘的位置,保持闹钟朝向镜头,与桌面平行,阴影自然投射于桌面。"
        }
    ],
    "task_metrics": {
        "TOTAL": 1,
        "FAILED": 0,
        "SUCCEEDED": 1
    },
    "usage": {
        "image_count": 1
    }
}

Model selection

  • wan2.7-image-pro, wan2.7-image (recommended): suitable for scenarios that require high editing precision or generating multiple images with coherent content.
    • Precise local editing: select a specific area in the image and move, replace, or add new elements to the objects in that area; suitable for e-commerce photo retouching and design draft adjustments
    • Multi-frame sequential image generation: outputs multiple images with a consistent style at once; suitable for comic storyboards, product series images, and sequential story illustrations
  • wan2.6-image: suitable for stylized editing scenarios with mixed text and images or multiple reference images; it can generate corresponding text content when generating images, and supports up to 4 reference images as input.
  • wan2.5-i2i-preview: suitable for simple image editing and multi-image fusion.
For the input and output specifications of each model, see Input image specifications and Output image resolution.

Showcase

Image-to-image set

Input image

Output image

Wan_图片生成_一位 20 岁的东亚男性,头发是卷卷的半长发,文艺气质,五官立体,眉眼清秀,穿着简约白色 T 恤或浅蓝色衬衫,少年感,自然气质。-2026-03-31-19-26-24

output

wan_image_reqid_57d7a71c-1932-4de8-8c32-be0f3fd5696f_n1-2026-03-31-19-32-44

output

Case 1: Photographic portraits
基础人物设定:一位 20 岁的东亚男性,头发是卷卷的半长发,文艺气质,五官立体,眉眼清秀,穿着简约白色 T 恤或浅蓝色衬衫,少年感,自然气质。
1. 民国文人风 (Republic Era Scholar)
提示词:
[基础面部描述] 人物形象为参考图1,身穿深青色长衫,佩戴圆框金丝眼镜,手持一把折扇,背景是老旧的上海书房,木质书架,暖黄色调,复古胶片质感,柔和的侧光,尘埃在光束中飞舞,文化气息,沉静内敛,哈苏中画幅,85mm 镜头,高分辨率,电影感调色,王家卫风格。
道具: 折扇 / 线装书 / 圆框眼镜
色调: 暖黄 / 深青 / sepia
2. 英伦绅士风 (British Gentleman)
提示词:
[基础面部描述] 人物形象为参考图1,穿着深灰色粗花呢西装三件套,佩戴复古机械腕表,手持高脚红酒杯,并看向酒杯,背景是古典图书馆或私人俱乐部,深色皮革沙发,伦勃朗光,暗调氛围,优雅高贵,冷峻眼神,细节丰富,纹理清晰,英国贵族气质,8k 分辨率,时尚杂志大片。
道具: 红酒杯 / 烟斗 / 机械表
色调: 深灰 / 酒红 / 暗金
3. 90s 港风复古 (90s HK Retro)
提示词:
[基础面部描述] 人物形象为参考图1,穿着水洗牛仔夹克或花衬衫,头发微乱,双手抱胸,背景是夜晚的霓虹灯牌街道,模糊的光斑,高颗粒感,色彩浓郁,红蓝撞色,王家卫风格,情绪化,迷离眼神,闪光灯直出效果,怀旧氛围,【全身镜头】。
色调: 霓虹红 / 深蓝 / 胶片绿
4. 新中式禅意 (New Chinese Zen)
提示词:
[基础面部描述]人物形象为参考图1,人物淡淡露齿笑, 穿着改良式白色中式立领上衣,手持折枝梅花,背景是极简的留白墙面或竹林,阳光洒在墙面上留下斑驳光影,清冷色调,宁静致远,东方美学,皮肤通透,高颗粒感,哑光,构图简洁,光影层次丰富,高端摄影,禅意氛围。
道具: 梅花枝
色调: 白 / 墨绿 / 浅灰
5. 复古艺术家 (Vintage Artist)
提示词:
[基础面部描述] 人物形象为参考图1,穿着沾有颜料的白色衬衫,系着棕色皮围裙,手持画笔或调色板,背景是干净的工作室,光线明亮,色彩斑斓的光影,专注的神情,看向手中颜料,不看镜头,头发略显凌乱,艺术气息,印象派色调,质感强烈。
道具: 画笔 / 调色板 / 素描本
色调: 暖光 / 多彩颜料 / 棕色
6. 经典黑白电影 (Classic Noir B&W)
提示词:
[基础面部描述] 人物形象为参考图1,穿着黑色高领毛衣,手持一根香烟,戴着黑色礼帽,背景是阴影交错的楼梯或走廊,高对比度黑白摄影,硬光照明,强烈的阴影,神秘感,冷硬派侦探风格,面部轮廓分明,皮肤纹理极致清晰,经典电影剧照,永恒感,侧脸特写,艺术摄影。
道具: 手杖 / 礼帽 / 墨镜
色调: 黑白 / 高对比度
Case 2: Visual design
图1:一张商业级产品摄影主视觉封面图,正视全景构图,一款复古未来主义风格的无线头戴式耳机悬浮于几何石膏体之上,耳机呈现完全对称美学,材质为香槟金金属与奶油白外壳,背景为深度虚化的温暖室内光影,光线柔和地勾勒出产品轮廓,画面留白处具有极强的呼吸感,营造静谧的听觉暗示,8k超高清分辨率,极简高级感。
图2:100mm微距镜头拍摄的产品材质特写,极近距离聚焦于耳机的伸缩臂连接处,清晰展示香槟金拉丝铝合金的金属纹理与CNC精密精割倒角,一道锐利的侧逆光在金属边缘形成星芒高光,背景深暗以突出金属的工业精密感,画质极度锐利,无噪点。
图3:极近距离的微距材质特写,聚焦于摩卡色蛋白皮耳罩的表面,通过侧光展现皮革细腻的毛孔纹理、柔软的按压褶皱与透气孔细节,传达极致的亲肤佩戴舒适度与回弹感,光影层次丰富,色调温暖湿润,超高清微距摄影。
图4:艺术化的产品爆炸视图,将复古未来主义耳机的内部发声单元、降噪芯片、电池模块与外部的胡桃木装饰片、金属框架进行悬浮拆解展示,背景为深邃的科技蓝,内部元件呈现半透明的全息科技质感,强调内部精密工艺与现代科技的结合,高科技商业海报风格。
图5:35mm人文镜头拍摄的佩戴场景图,特写模特的下颌线与颈部,展示佩戴这款香槟金耳机时的完美贴合度,自然暖调夕阳光从侧后方射入形成轮廓光,发丝边缘透着金光,模特肤色呈现健康自然的质感,营造沉浸式听歌的松弛生活感,背景为模糊的居家环境。
图6:致敬建筑光影的静物摄影,将耳机放置于极简的灰色混凝土桌面上,午后阳光透过百叶窗投下条纹状的硬光影,光影切过哑光奶油白机身与香槟金框架,形成明暗强烈的几何构成,凸显机身的立体廓形与材质对比,冷暖色调对撞,极简主义构图。
图7:俯视平铺构图的色彩方案展示图,并排陈列该系列三款不同配色的耳机,分别为银白、黑金、蓝铜配色,背景为肌理感极强的灰色羊毛毡布,柔和顶光照明,强调CMF设计的多样性与材质的细腻触感,画面整洁有序,设计杂志风格。
图8:品牌生活方式的全家福静物摄影,复古未来主义耳机被收纳在配套的精致皮箱旁,桌面上摆放着黑胶唱片机、一张正在旋转的黑胶唱片与一杯冒着热气的咖啡,背景有暖色调的氛围灯渲染,深胡桃木色调为主,传递慢生活与高保真音质结合的品牌生活哲学,电影感叙事光影。

Interactive Editing

Input image

Output image

5eecdaf48460cde5f7fd58249809b192a118accde85283f275b8339e1c4c24831b75b38faadcd24bec177c308ebd5304463ca8e345548eb5f551b6ba01cd2c8d2d9b5606fa569ff7ba4077816ac9b801464f65aedbcf494f4fb4c8ed7016461c-combine

5eecdaf48460cde5f7fd58249809b192a118accde85283f275b8339e1c4c24831b75b38faadcd24bec177c308ebd530460436714d0283cee289325430893028097a53a8e5d630fb1c2d4c85d8cbb68a4387575c4b03700344fb4c8ed7016461c-2026-03-31-19-13-38

Place the pattern framed in image 1 into the framed area in image 2

Multi-image Fusion

Input image

Output image

5eecdaf48460cde5544f9fac410016bc2fe4c1b4d23666c075b8339e1c4c24831b75b38faadcd24bec177c308ebd5304e9d05d028a65a9ac270ee730e44b8c75c6634a9b9a7a70240d438b02b2f2153dc68966b442378d1d4fb4c8ed7016461c-combine

5eecdaf48460cde5544f9fac410016bc2fe4c1b4d23666c075b8339e1c4c24831b75b38faadcd24bec177c308ebd53044b9a1d72dee2f8507ee704b9cef3832907ff1182f52507c9bc4737520762d46a722e658f57cda6524fb4c8ed7016461c-2025-12-29-19-11-31

Take a portrait photo of the boy in image 1 and the dog in image 2, with the boy holding the dog in his arms, both the person and the dog looking happy, soft studio lighting, blue textured background

5eecdaf48460cde5544f9fac410016bc2fe4c1b4d23666c075b8339e1c4c24831b75b38faadcd24bec177c308ebd5304f060ec7a363e318af9bfaaa5e07be972cfc1ea4e21b47637fcdb2dfc53130c40a8efed5defc408a04fb4c8ed7016461c-combine

5eecdaf48460cde5544f9fac410016bc2fe4c1b4d23666c075b8339e1c4c24831b75b38faadcd24bec177c308ebd5304922cbdef3e3c42f83239de6d0f35a8b76f0e38934cc5170f7a908ec12140fb0af6590c72bcf1ba6f4fb4c8ed7016461c-2025-12-29-19-15-53

Color the dress in image 1 based on the colors of the bird in image 2, full of artistic flair, with the clothing style unchanged and the model unchanged

Subject Feature Preservation

Input image

Output image

5eecdaf48460cde5544f9fac410016bc2fe4c1b4d23666c075b8339e1c4c24831b75b38faadcd24bec177c308ebd5304448a972b9f2ee7a7aadcc61495f4975a049f009e7721cbc833dc3a8005b1b026a54eaaec109d73484fb4c8ed7016461c-2025-12-29-20-00-21

5eecdaf48460cde5544f9fac410016bc2fe4c1b4d23666c075b8339e1c4c24831b75b38faadcd24bec177c308ebd5304cc1b4a509823c5fb5e60999898811f8b51d7419220a118c9ff82110bc9525725a9ad7338f75985794fb4c8ed7016461c-2025-12-29-20-00-21

Please generate a set of Polaroid photos in a 2x2 grid themed "Seasonal Changes", four photos in total. Each photo is taken in the same location, under a tree in a park, but respectively shows the scenes of spring, summer, autumn, and winter. The person's clothing should also match the season: a light jacket in spring, short sleeves in summer, a trench coat in autumn, and a scarf and thick coat in winter. Place this set of photos on a dining table.

Detection and Segmentation

Input image

Output image

5eecdaf48460cde5544f9fac410016bc2fe4c1b4d23666c075b8339e1c4c24831b75b38faadcd24bec177c308ebd5304b025e74206dc2cec5c2e587c3fe6fb135293836c9479220355470da15476dc934b26018061e9db0b4fb4c8ed7016461c-2025-12-29-19-54-33

5eecdaf48460cde5544f9fac410016bc2fe4c1b4d23666c075b8339e1c4c24831b75b38faadcd24bec177c308ebd530451385eb561b49b0fe1f2169526b6a7e15bd78940def3c640c801511c349f6df35dceb72f4d3755f94fb4c8ed7016461c-2025-12-29-19-54-33

Detect the laptop and alarm clock in the image, draw boxes and label them "laptop" and "clock"

5eecdaf48460cde5544f9fac410016bc2fe4c1b4d23666c075b8339e1c4c24831b75b38faadcd24bec177c308ebd530440256f9add4113787af5d4f3a55469b38ef2422f018076640eb7cb552584c02ee729fcb23fec3bca4fb4c8ed7016461c-2025-12-29-19-54-33

5eecdaf48460cde5544f9fac410016bc2fe4c1b4d23666c075b8339e1c4c24831b75b38faadcd24bec177c308ebd5304f0612d67f5c810ebef958385624ebd17323047aa5d00465d0e35257de5a2ea49d4b375d2e57693fa4fb4c8ed7016461c-2025-12-29-19-54-32

Segment the glass in the image

Element Extraction

Input image

Output image

5eecdaf48460cde5544f9fac410016bc2fe4c1b4d23666c075b8339e1c4c24831b75b38faadcd24bec177c308ebd53046b83761f1ab18c40e144f5db2b388e5f865ba9a5961d98b2710ce177c6a0f4baff63fe52259c44364fb4c8ed7016461c-2025-12-29-19-48-27

5eecdaf48460cde5544f9fac410016bc2fe4c1b4d23666c075b8339e1c4c24831b75b38faadcd24bec177c308ebd53048e2a0d1d2805d92ba8d45a3bd1368528dd76f517b21ad1f545eb4097610838497cbdb5196da94ff54fb4c8ed7016461c-2025-12-29-19-48-27

Extract clothing items from the uploaded photo, arrange them in a flat-lay display on a pure white background, preserving realistic details and material textures, in a fashion e-commerce style, suitable for clothing display.

Text Editing

Input image

Output image

5eecdaf48460cde5544f9fac410016bc2fe4c1b4d23666c075b8339e1c4c24831b75b38faadcd24bec177c308ebd530490f493eca22f34f0197173ddfdef17a04b34cb94813178b9d4eee36d246d3530a3e2fc6258cca0694fb4c8ed7016461c-2025-12-29-19-28-35

5eecdaf48460cde5544f9fac410016bc2fe4c1b4d23666c075b8339e1c4c24831b75b38faadcd24bec177c308ebd5304fe77776567f4ef79cb621289a6fdaa981f3364fe4c7c56265403b5d9d5ac43eaf5931f62db14952f4fb4c8ed7016461c-2025-12-29-19-28-35

Remove watermarks from the entire image

5eecdaf48460cde5544f9fac410016bc2fe4c1b4d23666c075b8339e1c4c24831b75b38faadcd24bec177c308ebd530476e971380812b1b9dbeac68272a27057175499fe84f0781c7b6fa6535f438c67f3556acc8c7324394fb4c8ed7016461c-2025-12-29-19-28-35

5eecdaf48460cde5544f9fac410016bc2fe4c1b4d23666c075b8339e1c4c24831b75b38faadcd24bec177c308ebd53047be52c6f41edecdefa77f0d93335d1492f1821b47dff7a1b08f60e99bdafcc84c31e3658fc593c904fb4c8ed7016461c-2025-12-29-19-28-35

Write "Time for Holiday?" casually on the beach by hand

5eecdaf48460cde5544f9fac410016bc2fe4c1b4d23666c075b8339e1c4c24831b75b38faadcd24bec177c308ebd5304fdb284f8d5c8ead814d11890da1a49411a6d9d41ad1bb2a4bf0b93d0bee5d792e8f5b419a3da9d534fb4c8ed7016461c-2025-12-29-19-28-34

5eecdaf48460cde5544f9fac410016bc2fe4c1b4d23666c075b8339e1c4c24831b75b38faadcd24bec177c308ebd5304df1c8787530497f4cc3bee0b84d3ba51d0353fceb8d0518ded6a25e8c0ddfec714f719154ac1c9354fb4c8ed7016461c-2025-12-29-19-28-34

Change 18 to 29 and JUNE to SEPTEMBER

Lens and Perspective Editing

Input image

Output image

image (2)-2025-12-29-19-42-44

image (3)-2025-12-29-19-42-44

Keep the person's features unchanged and generate front, side, and back views

5eecdaf48460cde5544f9fac410016bc2fe4c1b4d23666c075b8339e1c4c24831b75b38faadcd24bec177c308ebd5304a53988b2efdd2fb6b95cb3b1b02701e6ff2c4902170b1ee230a9b4e3726a891c93646d68b821de294fb4c8ed7016461c-2025-12-29-19-42-43

5eecdaf48460cde5544f9fac410016bc2fe4c1b4d23666c075b8339e1c4c24831b75b38faadcd24bec177c308ebd530428783dee341e41eb06234dfb75bd149d774f4850000123559a98bcd7ece97dc4a6c3cefa983ae8ac4fb4c8ed7016461c-2025-12-29-19-42-43

Retake this photo with a fisheye lens

Input Description

Input Image Specifications

Type

wan2.7-image-pro、wan2.7-image

wan2.6-image

wan2.5-i2i-preview

Number of input images

0-9 images (0 images corresponds to text-to-image mode)

Image editing: 1-4 images / Image-text layout: 0-1 images

1-3 images

Image Format

JPEG, JPG, PNG (transparent channels not supported), BMP, WEBP

JPEG, JPG, PNG (transparent channels not supported), BMP, WEBP

JPEG, JPG, PNG (transparent channels not supported), BMP, WEBP

Image width and height range

[240, 8000] pixels

[240, 8000] pixels

[384, 5000] pixels

File Size

≤ 20MB

≤ 10MB

≤ 10MB

Aspect Ratio

[1:8, 8:1]

Unlimited

[1:4, 4:1]

Image input order

When multiple images are input, the image order is defined by their order in the array. Therefore, the image numbers referenced by the prompt must correspond one-to-one with the order in the image array. For example: the first image in the array is "Image 1", the second is "Image 2", or use marker notation such as "[Image 1]" and "[Image 2]".
{
    "content": [
        {"text": "编辑指令,如:将图1中的闹钟放置到图2的餐桌的花瓶旁边位置"},
        {"image": "https://example.com/image1.png"},
        {"image": "https://example.com/image2.png"}
    ]
}

Input image

Output image

image (19)-转换自-png

Image 1

image (20)-转换自-png

Image 2

04e0fc39-7ad6-41e0-9df9-1f69ac3ce825-转换自-png

Prompt: Move Image 1 onto Image 2

36ed450d-bd54-4169-b13f-3d0f26d9d360-转换自-png

Prompt: Move Image 2 onto Image 1

Image input methods

Images can be passed in using the following methods:

Method 1: Public URL

  • Provide a publicly accessible image URL, supporting HTTP or HTTPS protocols.
  • Example value: https://xxxx/img.png.
  • Applicable scenario: the image is already hosted on object storage (such as OSS) or a public image hosting service.
Convert the image file into a Base64-encoded string and concatenate it in the following format: data:{MIME_type};base64,{base64_data}.
  • Example value: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABDg......(only a fragment is shown due to length limits). When calling, you must pass the complete string.
  • {base64_data}: the string obtained by Base64-encoding the image file.
  • {MIME_type}: the media type of the image, which must match the file format.

    Image format

    MIME Type

    JPEG

    image/jpeg

    JPG

    image/jpeg

    PNG

    image/png

    BMP

    image/bmp

    WEBP

    image/webp

  • Use for local images, private images, or scenarios that require encrypted transmission.

Code example: Base64 encoding for an image

import os
import base64
import mimetypes

# 格式为 data:{mime_type};base64,{base64_data}
def encode_file(file_path):
    mime_type, _ = mimetypes.guess_type(file_path)
    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}"

# 调用编码函数,请将 "/path/to/your/image.png" 替换为您的本地图片文件路径,否则无法运行
image = encode_file("/path/to/your/image.png")
  • Python SDK: Supports both absolute and relative paths. The file path rules are as follows:

    System

    Input file path

    Example (absolute path)

    Example (relative path)

    Linux or macOS

    file://{absolute or relative path of the file}

    file:///home/images/test.png

    file://./images/test.png

    Windows

    file://D:/images/test.png

    file://./images/test.png

  • Java SDK: Supports only the absolute path. The file path rules are as follows:

    System

    Input file path

    Example (absolute path)

    Linux or macOS

    file://{absolute path of the file}

    file:///home/images/test.png

    Windows

    file:///{absolute path of the file}

    file:///D:/images/test.png

  • Use for quick testing in local development.

Key features

1. Instruction following (prompts)

Parameters: messages.content.text or input.prompt (required), negative_prompt (optional).
  • text or prompt (Positive prompt): Describe content, subjects, scenes, styles, lighting, and composition for the output image.
  • negative_prompt (Negative prompt): Describe content that you do not want to appear in the image, such as "blurry" or "extra fingers". It is only used to help optimize generation quality.

Parameter

wan2.7-image-pro、wan2.7-image

wan2.6-image

wan2.5-i2i-preview

text

Required, up to 5,000 characters

Required, up to 2,000 characters

Not supported

prompt

Not supported

Not supported

Required, up to 2,000 characters

negative_prompt

Not supported

Supported, up to 500 characters

Supported, up to 500 characters

2. Enable intelligent prompt rewriting

Parameter: parameters.prompt_extend (bool, defaults to true). This feature automatically expands and optimizes short prompts to improve the output image quality. Enabling this feature adds extra processing time. Best practices:
  • Recommended to enable: When the input prompt is concise or broad, this feature can improve the image quality.
  • Recommended to disable: If you need to control the image details, have already provided a detailed description, or are sensitive to response latency. Explicitly set the parameter prompt_extend to false.

Parameter

wan2.7-image-pro、wan2.7-image

wan2.6-image

wan2.5-i2i-preview

prompt_extend

Not supported

Supported (image editing mode only)

Supported

3. Set the output image resolution

Parameter: parameters.size (string), in the format "width*height".
The 1K tier of the same name is defined differently across models: the wan2.7 series outputs a total pixel count close to 10241024, while wan2.6-image is close to 12801280. Pay attention to the output resolution differences when switching models.
Parameterwan2.7-image-pro、wan2.7-imagewan2.6-imagewan2.5-i2i-preview
sizeMethod 1: Specify the output image resolution (recommended)In editing mode (with at least one image passed), the optional output resolution tiers are: 1K, 2K (default).
  • 1K: The output total pixels are close to 1024*1024, with the aspect ratio matching the last input image.
  • 2K: The output total pixels are close to 2048*2048, with the aspect ratio matching the last input image.
Method 2: Specify the width and height pixel values of the generated image
  • Total pixels range from [768768, 20482048], with an aspect ratio range of [1:8, 8:1].
Only wan2.7-image-pro in text-to-image scenarios supports 4K resolution.
Method 1: Reference the input image ratio (recommended)In editing mode (enable_interleave=false), the optional output resolution tiers are: 1K (default), 2K.
  • 1K: The output total pixels are close to 1280*1280, with the aspect ratio matching the last input image.
  • 2K: The output total pixels are close to 2048*2048, with the aspect ratio matching the last input image.
Method 2: Specify the width and height pixel values of the generated image
  • Total pixels range from [768768, 20482048], with an aspect ratio range of [1:4, 4:1].
The actual output image pixel values will be the closest multiple of 16 to the specified value.
Only supports specifying the width and height pixel values of the generated image
  • Total pixels range from [768768, 12801280], with an aspect ratio range of [1:4, 4:1].
  • If size is not specified, the system generates an image with a total pixel count of 1280*1280 by default, with an aspect ratio matching the last input image.

4. Interactive precise editing

Use the parameter parameters.bbox_list to box-select the objects or locations in the image to edit, achieving more accurate editing results. Only supported by wan2.7-image-pro and wan2.7-image.
  • List length: Must match the number of input images. Use an empty list [] for images that don't require editing.
  • Coordinate format: [x1, y1, x2, y2] (top-left x, top-left y, bottom-right x, bottom-right y). Use absolute pixel coordinates of the original image, with the top-left corner as (0, 0), the x-axis pointing right, and the y-axis pointing down. If you use a vision model (such as qwen3.6-plus) to locate the target region, it returns normalized coordinates [0, 999]. Convert them to absolute pixel coordinates with the auxiliary code below before passing them in.
  • Quantity limit: A maximum of 2 bounding boxes per image.
Example: Input 3 images, where image 2 has no selection box and image 1 has two:
[
  [[0, 0, 12, 12], [25, 25, 100, 100]],
  [],
  [[10, 10, 50, 50]]
]
curl --location 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--data '{
    "model": "wan2.7-image-pro",
    "input": {
        "messages": [
            {
                "role": "user",
                "content": [
                    {"image": "https://img.alicdn.com/imgextra/i3/O1CN0157XGE51l6iL9441yX_!!6000000004770-49-tps-1104-1472.webp"},
                    {"image": "https://img.alicdn.com/imgextra/i3/O1CN01SfG4J41UYn9WNt4X1_!!6000000002530-49-tps-1696-960.webp"},
                    {"text": "把图1的闹钟放在图2的框选的位置,保持场景和光线融合自然"}
                ]
            }
        ]
    },
    "parameters": {
        "bbox_list": [[],[[989, 515, 1138, 681]]],
        "size": "2K",
        "n": 1,
        "watermark": false
    }
}'
Method 1: Draw bounding boxes with OpenCVDraw bounding boxes by dragging the mouse on the image for precise and intuitive selection:
# 安装依赖:pip install opencv-python
import cv2
import urllib.request

# 下载示例图片(替换为您自己的图片 URL 或本地路径)
image_url = "https://img.alicdn.com/imgextra/i3/O1CN01SfG4J41UYn9WNt4X1_!!6000000002530-49-tps-1696-960.webp"
urllib.request.urlretrieve(image_url, "example.webp")

# 读取图片并弹出交互窗口
img = cv2.imread("example.webp")
# 在弹出的窗口中用鼠标拖拽画框,按 Enter 确认选区,按 Esc 取消
x, y, w, h = cv2.selectROI("Draw bounding box (Enter=confirm, Esc=cancel)", img)
cv2.destroyAllWindows()

# 将 OpenCV 返回的 (x, y, w, h) 转换为 bbox_list 所需的 [x1, y1, x2, y2] 格式
# 坐标系:原点在图片左上角,x 轴向右,y 轴向下,单位为像素
bbox = [x, y, x + w, y + h]
print(f"框选坐标: {bbox}")  # 将此坐标传入 parameters.bbox_list
Method 2: Visual understanding modelUse qwen3.6-plus to automatically identify target region coordinates by describing the target in natural language:
# 安装依赖:pip install dashscope pillow
import os
import json
import dashscope
from PIL import Image
import urllib.request

client = dashscope.Client(
    api_key=os.getenv('DASHSCOPE_API_KEY'),
    workspace="{WorkspaceId}",
    region="cn-beijing",
)

def get_bbox_list(image, prompt):
    """
    通过 qwen3.6-plus 识别图片中的目标区域,返回绝对像素坐标列表。

    Args:
        image: 图片 URL 或本地路径(本地路径格式为 "file:///absolute/path.png")
        prompt: 自然语言描述,如 "咖啡杯"、"盘子里所有的水果"、"盘子正中间的水果"

    Returns:
        [[x1, y1, x2, y2], ...] 绝对像素坐标,可直接传入 bbox_list
    """
    # 将用户描述与返回格式指令拼接
    full_prompt = (
        prompt + "\n"
        "请根据以上描述,返回对应区域的坐标。\n"
        "最多返回2个区域,优先返回最匹配的目标。\n"
        "严格按照JSON二维列表格式返回:[[x1, y1, x2, y2], ...]\n"
        "每组坐标:[左上角x, 左上角y, 右下角x, 右下角y]\n"
        "坐标系以图片左上角为(0,0),x轴向右,y轴向下。\n"
        "如果只有一个区域,也必须使用二维列表:[[x1, y1, x2, y2]]\n"
        "只返回JSON列表,不要返回其他任何内容。"
    )

    messages = [
        {'role': 'user',
         'content': [
             {'image': image},
             {'text': full_prompt}
         ]}
    ]

    response = client.multimodal.chat.create(
        model='qwen3.6-plus',
        messages=messages,
    )

    text = response.output_text
    text = text.replace("```json", "").replace("```", "").strip()
    coords = json.loads(text)

    # 兼容模型返回一维列表 [x1,y1,x2,y2] 的情况
    if coords and not isinstance(coords[0], list):
        coords = [coords]

    # 获取图片尺寸,用于坐标转换
    if image.startswith("file://"):
        local_path = image[len("file://"):]
        img = Image.open(local_path)
    else:
        tmp_path = "temp_bbox_image"
        urllib.request.urlretrieve(image, tmp_path)
        img = Image.open(tmp_path)
    width, height = img.size

    # qwen3.6-plus 等 Qwen3-VL 系列模型返回归一化坐标 [0, 999],此处转换为绝对像素坐标
    bbox_list = []
    for box in coords:
        bbox_list.append([
            int(box[0] / 1000 * width),
            int(box[1] / 1000 * height),
            int(box[2] / 1000 * width),
            int(box[3] / 1000 * height)
        ])

    return bbox_list

# === 使用示例 ===
image_url = "https://img.alicdn.com/imgextra/i3/O1CN01ewUWhg1eS3VqJ3wap_!!6000000003869-49-tps-2048-2048.webp"

# 按名称选取目标
bbox = get_bbox_list(image_url, "咖啡杯")           # [[x1, y1, x2, y2]]

# 按位置描述选取目标
bbox = get_bbox_list(image_url, "盘子正中间的水果")  # [[x1, y1, x2, y2]]

# 描述一个区域
bbox = get_bbox_list(image_url, "薰衣草盆栽")

# 结果可作为 bbox_list 数组中的元素
# 注意:单张图片最多支持 2 个边界框

Billing and rate limits

  • Free quota and pricing: Model list and pricing.
  • For rate limits, see Wanxiang.
  • Billing:
    • Billing is based on the number of images successfully generated. You are charged only after the API returns a task_status of SUCCEEDED and the image is successfully generated.
    • Failed model calls or processing errors do not incur any fees or consume the free quota.

API reference

Each model uses a different endpoint and request structure:

Model

Endpoint(Example for the China (Beijing) region)

wan2.7-image 、 wan2.7-image-pro、wan2.6-image

Sync API: POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation

Async API: POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/image-generation/generation

wan2.5-i2i-preview

Async API: POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/image2image/image-synthesis

  • wan2.7 / wan2.6: Use the messages format. In the messages[].content array, pass the image in the image parameter and the prompt in the text parameter.
  • wan2.5: Pass the image in the input.images array and the prompt in the input.prompt parameter.
"input": {
    "messages": [
        {
            "role": "user",
            "content": [
                {"image": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20251229/pjeqdf/car.webp"},
                {"image": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20251229/xsunlm/paint.webp"},
                {"text": "把图2的涂鸦喷绘在图1的汽车上"}
            ]
        }
    ]
}
For input and output parameters, see Wan2.7 - image generation and editing, Wan2.6 - image generation and editing, Wanxiang – General Image Editing 2.5