Skip to main content

Image Editing - Wan2.5 to 2.7

The Wan image editing model series supports multi-image input and multi-image output, enabling capabilities such as image editing, multi-image fusion, subject feature preservation, and object detection and segmentation through text instructions.

QuickStart

This example demonstrates how to use the wan2.7-image-pro model to generate an edited image based on two input images and a prompt.
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 you make a 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
Make sure the DashScope Python SDK version is at least 2.1.0, and the DashScope Java SDK version is at least 2.22.13.
  • Python
  • Java
  • curl

Request example

import os
import base64
import mimetypes
import urllib.request
import dashscope

# This configuration is for the Singapore region. Replace {WorkspaceId} with your actual workspace ID. The region value varies by region.
# If the environment variable is not configured, replace the following line with your Model Studio API key: api_key="sk-xxx"
# API keys differ by region. Get an API key: https://www.alibabacloud.com/help/model-studio/get-api-key
client = dashscope.Client(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    workspace="{WorkspaceId}",
    region="ap-southeast-1",
)

# --- Base64 encoding function ---
# The Base64 encoding format is 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编码 - 适合私有图片或需要加密传输的场景
"""
# [Method 1] Use a public image 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"

# [Method 2] Use a local file (supports absolute and relative paths)
# image_1 = "file:///path/to/your/car.png"
# image_2 = "file:///path/to/your/paint.png"

# [Method 3] Use a Base64-encoded image
# 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 submits the task and waits, returning the completed task result directly
job = client.images.generate(
    model="wan2.7-image-pro",
    prompt="把图2的涂鸦喷绘在图1的汽车上",
    # Reference images; local files are supported, such as "file:///path/to/your/car.png"
    image_urls=[image_1, image_2],
    watermark=False,
    n=1,
    size="2K",  # wan2.7-image-pro supports 4K resolution only for text-to-image generation. Image editing and multi-image generation support up to 2K resolution.
)

# Extract the result image URL and save the image to a local file.
for i, image_url in enumerate(job.image_urls):
    file_name = f"output_{i}.png"
    # The result URL is valid for 24 hours. Download the image in a timely manner.
    urllib.request.urlretrieve(image_url, file_name)
    print(f"Image saved to {file_name}")

Response example

The URL is valid for 24 hours. Download the image in time.
{
    "status_code": 200,
    "request_id": "81d868c6-6ce1-92d8-a90d-d2ee71xxxxxx",
    "code": "",
    "message": "",
    "output": {
        "text": null,
        "finish_reason": null,
        "choices": [
            {
                "finish_reason": "stop",
                "message": {
                    "role": "assistant",
                    "content": [
                        {
                            "image": "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/xxxxxx.png?Expires=xxxxxx",
                            "type": "image"
                        }
                    ]
                }
            }
        ],
        "audio": null,
        "finished": true
    },
    "usage": {
        "input_tokens": 18790,
        "output_tokens": 2,
        "characters": 0,
        "image_count": 1,
        "size": "2985*1405",
        "total_tokens": 18792
    }
}
wan2.5-i2i-preview uses a different API endpoint and parameter passing method. Its calling examples are as follows:
  • Synchronous call
  • Asynchronous call
Ensure that the DashScope Python SDK version is no earlier than 1.25.2 and the DashScope Java SDK version is no earlier than 2.22.2.If the version is too low, errors such as "url error, please check url!" may be triggered. Refer to Install or upgrade the SDK to update.
  • Python
  • Java
This example supports three image input methods: public URL, Base64 encoding, and local file path.
Request example
import base64
import mimetypes
from urllib.parse import urlparse, unquote
from pathlib import PurePosixPath

import dashscope
import requests
import os

# The following configuration is for Singapore. Replace {WorkspaceId} with your Model Studio workspace ID. The region value varies by region
# If the environment variable is not configured, replace the following line with your Model Studio API key: api_key="sk-xxx"
# The API Key differs between the Singapore and Beijing regions. Get your API Key: https://www.alibabacloud.com/help/model-studio/get-api-key
client = dashscope.Client(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    workspace="{WorkspaceId}",
    region="ap-southeast-1",
)

# --- 输入图片:使用 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_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----')
# 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 in a timely manner.
{
    "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
    }
}

Model Selection

  • wan2.7-image-pro and wan2.7-image (recommended): suitable for scenarios that require high editing precision or need to generate multiple images with coherent content.
    • Precise local editing: select a specified region in the image, then move, replace, or add new elements to the objects in that region. Applicable to e-commerce photo retouching and design draft adjustments
    • Multi-frame continuous image generation: outputs multiple images with a consistent style at once, applicable to comic storyboarding, product series images, and sequential story images
  • 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.

Showcases

Image-to-image set generation

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: Portrait photography
基础人物设定:一位 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 at 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 man in image 1 and the dog in image 2, with the man holding the dog in his arms and both of them looking happy, under soft studio lighting against a blue textured background

5eecdaf48460cde5544f9fac410016bc2fe4c1b4d23666c075b8339e1c4c24831b75b38faadcd24bec177c308ebd5304f060ec7a363e318af9bfaaa5e07be972cfc1ea4e21b47637fcdb2dfc53130c40a8efed5defc408a04fb4c8ed7016461c-combine

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

Recolor the dress in image 1 based on the colors of the bird in image 2, with an artistic feel, keeping the dress style 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 four instant photos arranged in a 2x2 grid with a "Seasonal Changes" theme. Each photo is taken at the same location, under a tree in a park, but depicts one of the four seasons: spring, summer, autumn, or 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 heavy 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 around them 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 outfit items from the uploaded photo, arrange them in a flat-lay layout 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?" by hand in the sand on the beach

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

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

Change 18 to 29 and JUNE to SEPTEMBER

Camera 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 the front view, side view, and back view

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

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

Retake this photo with a fisheye lens

Input instructions

Input image specifications

Type

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

wan2.6-image

wan2.5-i2i-preview

Number of input images

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

Image editing: 1 to 4 images / Image-text composition: 0 to 1 images

1 to 3 images

Image Format

JPEG, JPG, PNG (transparency channel not supported), BMP, WEBP

JPEG, JPG, PNG (transparency channel not supported), BMP, WEBP

JPEG, JPG, PNG (transparency channel 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 in 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 you can use marker forms 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 that supports the HTTP or HTTPS protocol.
  • 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 making the call, you must pass in the complete string.
  • {base64_data}: The Base64-encoded string of 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

  • Applicable scenarios: local images, private images, or scenarios that require encrypted transmission.

Sample code: Image Base64 encoding

import os
import base64
import mimetypes

# The format is 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}"

# Call the encoding function. Replace "/path/to/your/image.png" with the path to your local image file, otherwise the code will not run.
image = encode_file("/path/to/your/image.png")
  • Python SDK: Supports both absolute and relative paths of files. The file path rules are as follows:

    System

    Input file path

    Example (absolute path)

    Example (relative path)

    Linux or macOS

    file://{absolute or relative file path}

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

    file://./images/test.png

    Windows

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

    file://./images/test.png

  • Java SDK: Only supports absolute paths of files. The file path rules are as follows:

    System

    Input file path

    Example (absolute path)

    Linux or macOS

    file://{absolute file path}

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

    Windows

    file:///{absolute file path}

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

  • Applicable scenarios: Suitable for quick testing in a local development environment.

Key capabilities

1. Instruction following (prompt)

Parameters: messages.content.text or input.prompt (required), and negative_prompt (optional).
  • text \ prompt (positive prompt): Describes the content, subject, scene, style, lighting, and composition you want to see in the image.
  • negative_prompt (negative prompt): Describes the content you do not want to appear in the image, such as "blur" 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 5000 characters

Required, up to 2000 characters

Not supported

prompt

Not supported

Not supported

Required, up to 2000 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 output image quality. Enabling this feature adds extra processing time. Best practices:
  • Recommended to enable: When the input prompt is brief or broad, this feature can improve image quality.
  • Recommended to disable: If you need to control image details, have already provided a detailed description, or are sensitive to response latency. Please explicitly set the prompt_extend parameter 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 same tier 1K 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 differences in output resolution when switching models.
Parameterwan2.7-image-pro、wan2.7-imagewan2.6-imagewan2.5-i2i-preview
sizeMethod 1: Specify the resolution of the output image (recommended)In edit mode (with at least one image provided), the available output resolution tiers are 1K and 2K (default).
  • 1K: The total pixel count of the output is close to 1024*1024, and the aspect ratio is the same as that of the last input image.
  • 2K: The total pixel count of the output is close to 2048*2048, and the aspect ratio is the same as that of the last input image.
Method 2: Specify the width and height pixel values of the generated image
  • The total pixel count is between [768768, 20482048], and the aspect ratio range is [1:8, 8:1].
Only wan2.7-image-pro in the text-to-image scenario supports 4K resolution
Method 1: Reference the aspect ratio of the input image (recommended)In edit mode (enable_interleave=false), the available output resolution tiers are 1K (default) and 2K.
  • 1K: The total pixel count of the output is close to 1280*1280, and the aspect ratio is the same as that of the last input image.
  • 2K: The total pixel count of the output is close to 2048*2048, and the aspect ratio is the same as that of the last input image.
Method 2: Specify the width and height pixel values of the generated image
  • The total pixel count is between [768768, 20482048], and the aspect ratio range is [1:4, 4:1].
The actual pixel values of the output image are multiples of 16 close to the specified values.
Only specifying the width and height pixel values of the generated image is supported
  • The total pixel count is between [768768, 12801280], and the aspect ratio range is [1:4, 4:1].
  • If size is not specified, the system generates an image with a total pixel count of 1280*1280 by default, and the aspect ratio is the same as that of the last input image.

4. Interactive precise editing

The parameters.bbox_list parameter boxes the objects or areas in the image that need editing, achieving more accurate editing results. Only wan2.7-image-pro and wan2.7-image support this.
  • Correspondence: The list length must match the number of input images. If an image does not need editing, pass an empty list [] in the corresponding position.
  • Coordinate format: [x1, y1, x2, y2] (top-left x, top-left y, bottom-right x, bottom-right y), using absolute pixel coordinates of the original image, with the top-left corner at (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 area, it returns normalized coordinates [0, 999]. Convert them to absolute pixel coordinates using the auxiliary code below before passing them in.
  • Quantity limit: A single image supports at most 2 bounding boxes.
Example: 3 images are input, where the 2nd image has no box selection and the 1st image has two box selections:
[
  [[0, 0, 12, 12], [25, 25, 100, 100]],
  [],
  [[10, 10, 50, 50]]
]
curl --location 'https://{WorkspaceId}.ap-southeast-1.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 boxes with OpenCVDrag the mouse on the image to draw a box, which is precise and intuitive:
# Install dependencies: pip install opencv-python
import cv2
import urllib.request

# Download a sample image (replace with your own image URL or local path)
image_url = "https://img.alicdn.com/imgextra/i3/O1CN01SfG4J41UYn9WNt4X1_!!6000000002530-49-tps-1696-960.webp"
urllib.request.urlretrieve(image_url, "example.webp")

# Read the image and open an interactive window
img = cv2.imread("example.webp")
# Drag the mouse in the pop-up window to draw a box. Press Enter to confirm, press Esc to cancel
x, y, w, h = cv2.selectROI("Draw bounding box (Enter=confirm, Esc=cancel)", img)
cv2.destroyAllWindows()

# Convert the (x, y, w, h) returned by OpenCV to the [x1, y1, x2, y2] format required by bbox_list
# Coordinate system: origin at the top-left corner, x-axis points right, y-axis points down, unit is pixels
bbox = [x, y, x + w, y + h]
print(f"框选坐标: {bbox}")  # Pass these coordinates to parameters.bbox_list
Method 2: Vision understanding modelUse qwen3.6-plus to automatically identify the coordinates of the target area. Simply describe the target in natural language to obtain the coordinates:
# Install dependencies: pip install dashscope pillow
import os
import json
import dashscope
from PIL import Image
import urllib.request

# This configuration is for the Singapore region. Replace {WorkspaceId} with your actual workspace ID. The region value varies by region.
client = dashscope.Client(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    workspace="{WorkspaceId}",
    region="ap-southeast-1",
)

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

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

    Returns:
        [[x1, y1, x2, y2], ...] 绝对像素坐标,可直接传入 bbox_list
    """
    # Concatenate user description with return format instructions
    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)

    # Handle the case where the model returns a 1D list [x1,y1,x2,y2]
    if coords and not isinstance(coords[0], list):
        coords = [coords]

    # Get image dimensions for coordinate conversion
    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 and other Qwen3-VL models return normalized coordinates [0, 999]; convert them to absolute pixel coordinates here
    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

# === Usage examples ===
image_url = "https://img.alicdn.com/imgextra/i3/O1CN01ewUWhg1eS3VqJ3wap_!!6000000003869-49-tps-2048-2048.webp"

# Select target by name
bbox = get_bbox_list(image_url, "咖啡杯")           # [[x1, y1, x2, y2]]

# Select target by position description
bbox = get_bbox_list(image_url, "盘子正中间的水果")  # [[x1, y1, x2, y2]]

# Describe a region
bbox = get_bbox_list(image_url, "薰衣草盆栽")

# Results can be used as elements in the bbox_list array
# Note: A maximum of 2 bounding boxes per image

Billing and rate limits

  • For the model free quota and billing unit price, see Model list and prices.
  • For model rate limits, see Wan.
  • Billing details:
    • Billing is based on the number of images successfully generated. You are billed only after the API returns task_status as SUCCEEDED and the images are successfully generated.
    • Failed model calls or processing errors incur no charges and do not consume the free quota.

API reference

Each model uses different endpoints and request structures:

Model

Endpoint (with the Singapore region as an example)

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

Synchronous endpoint: POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation

Asynchronous endpoint: POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/image-generation/generation

When calling, replace WorkspaceId with your actual Workspace ID.

wan2.5-i2i-preview

Asynchronous endpoint: POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/image2image/image-synthesis

When calling, replace WorkspaceId with your actual Workspace ID.

  • wan2.7 / wan2.6: messages format. In the messages[].content array, images are passed via image, and prompts via text.
  • wan2.5: Images are passed via the input.images array, and prompts via input.prompt
"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 Wan-Image Generation and Editing 2.7 API reference, Wan-Image Generation and Editing 2.6 API reference, and Wan-Universal Image Editing 2.5 API reference.