Overview
Based on the product images and description provided by the user, generate the e-commerce platform (Taobao/Tmall/JD) product detail images(9 images) and/or product carousel images(5 images).
Core Principles
- Product images must be faithful. The patterns, text, logos, and colors in the product images provided by the user must not be changed in any way. Detail images and carousel images are layout design and copy packaging done on the basis of the original images, not regenerating the product.
- Zero user operation. Everything is completed automatically in the background, and the image results are output directly in the conversation. Do not open a visible browser window, and do not make the user export manually.
- Environment adaptive. Prefer using
run_command+ Python PIL to precisely render Chinese text; if the environment does not support it, automatically downgrade to thegenerate_imagesolution.
When to Use
- The user uploaded product images and requested generation of detail images or carousel images
- The user provided a text description of the product and requested generation of e-commerce images
- The user mentioned keywords such as "Taobao detail image", "product image", "e-commerce image", "carousel image", "main image", etc.
Information to Collect
| Required | Additionally required for carousel images | Optional |
|---|---|---|
| Product images (at least 1) | Brand Logo (text or image) | Specifications (size/material, etc.) |
| Product description | Promotion content (e.g., "10% off for 1 item") | Brand story |
| Core selling points |
Input Processing:
- Has images → Observe the product in the images, infer the category, appearance, and selling points
- Text only → Extract information from the description, use
generate_imageto first generate 1 product image - If information is insufficient, ask follow-up questions,at most 1 round of follow-up questions, and infer the rest from the images and description
⚠️ The user may only want carousel images or only detail images. If the user explicitly says they only want one of them, skip the other. When uncertain, generate both by default.
⚠️ Execution Checklist (Must Read)
You must generate 14 images, not 1! Execute step by step as follows:
Carousel Images (5 images)
- Use
generate_imageto generate model image 1 (pass the user's original image as ImagePaths) - Use
generate_imageto generate model image 2 (pass the user's original image as ImagePaths) - Use
generate_imageto generate model image 3 (pass the user's original image as ImagePaths) - Use a PIL script or
generate_imageto overlay the Logo + promotion bar + selling point keywords on the model images, generating carousel_01 ~ carousel_04 - Use a PIL script or
generate_imageto generate carousel_05 (white background image, Logo only)
Detail Images (9 images)
generate_image→ Main image cover (pass the original image)generate_image→ Selling point 1 (pass the original image)generate_image→ Selling point 2 (pass the original image)generate_image→ Selling point 3 (pass the original image)generate_image→ Detail annotation image (pass in the original image)generate_image→ Wearing/usage scenariogenerate_image→ Product specification table (pass in the original image)generate_image→ Size/specification tablegenerate_image→ After-sales guarantee
Key Rules
- Each image must be generated with a separate call to
generate_image, do not try to generate multiple images at once - The user's original image must be passed in as ImagePaths, otherwise the AI will draw a different product
- Do not write the Logo and campaign text in the generate_image prompt(the AI will distort Chinese characters); use PIL post-processing instead
- The background should not be pure white, it should have a sense of scene
Process
输入 → 商品分析 → 风格判断 → 并行生成(详情图 + 轮播图)→ 直接输出
Part 1: Product Analysis
Extract from user input:
| Analysis Item | Source |
|---|---|
| Product Category | Image observation + description (tops/pants/shoes/accessories/3C/home/food...) |
| Core Selling Points (2-4) | Description + inference |
| Target Audience | Description + inference (children/adults/men/women) |
| Product Style | Image observation (trendy/cool/Japanese-style/sporty/sweet/minimalist/business...) |
| Selling Point Keywords | Extract 2-3 core words from the description (such as "fleece-lined", "warm") |
Part 2: Style Determination
| Style | Applicable Categories | Color Scheme |
|---|---|---|
| Minimalist Premium | Digital 3C, premium home, skincare, business apparel | Background #fafafa, text #1a1a1a, accent #c9a96e |
| Marketing Promotion | Food snacks, daily necessities, affordable products | Background #fff, emphasis #e63946, accent #ff6b35 |
| Lifestyle Recommendation | Fashion apparel, beauty, maternal and baby, children's clothing | Background #fdf8f3, text #3d3024, accent #c17a50 |
| Tech Future | Electronic products, smart devices, digital accessories | Background #0a0a0a, text #fff, accent #00d4ff |
Part 3: Carousel Image Generation (5 images)
Specifications
- Size:800×800 pixels (square)
- 5 images: 3 model/scene images + 1 scene-based original image + 1 product close-up
- Top left: brand Logo
- The first 4 images show selling point keywords on the left(extracted from the description, such as "fleece-lined", "warm"), semi-transparent background bar + white text
- Bottom of the first 4 images: promotional campaign bar
- The background should not be pure white/pure gray, it should match the product style
Step A: Generate model/scene images
Use generate_image to generate 3 images,the user's original image must be passed in as ImagePaths。
⚠️ Determine the composition and subject based on the product category:
| Category | Subject | Composition | Prompt Keywords |
|---|---|---|---|
| Tops (hoodies/T-shirts/jackets) | Model | Half-body shot (head to hips) | upper body shot, waist-up, cropped at hip |
| Pants/skirts | Model | Lower body | lower body focus, hip to feet |
| Full-body outfit/dress | Model | Full-body shot | full body shot |
| Shoes | Foot close-up | Close-up | close-up of shoes on feet, ground level angle |
| Hat/Scarf | Model | Head-and-shoulders close-up | close-up, head and shoulders |
| Digital 3C/Home | Product | Styled scene shot | product in lifestyle setting, styled flat lay |
| Food | Product | Food photography | food photography, styled plating, appetizing |
⚠️ Background matches product style:
| Style | Background scene | Prompt reference |
|---|---|---|
| Trendy/Street | Graffiti wall, brick wall, city nightscape | urban concrete wall with graffiti, city night lights bokeh |
| Japanese/Artsy | Courtyard, cafe, park | cozy cafe interior, park with warm sunlight |
| Sporty and energetic | Playground, outdoor sunlight | playground, outdoor bright sunlight |
| Sweet and cute | Flower wall, amusement park | pink flower wall, pastel balloons |
| Minimalist and premium | Marble countertop, minimalist space | marble surface, minimal white interior |
| Tech feel | Dark desktop, neon lights | dark desk setup, neon accent lighting |
Prompt template (apparel):
A [age]-year-old Asian [boy/girl/man/woman] model wearing [商品英文描述],
[姿态描述], [场景背景],
[构图方式] focusing on the [商品],
e-commerce fashion photography,
[lighting], professional catalog style, high resolution
Prompt template (non-apparel):
Product photography of [商品英文描述],
[场景/摆放方式], [背景描述],
e-commerce product photography,
soft studio lighting, professional, high resolution, 800x800
3 images using different poses/angles and backgrounds.
Step B: Overlay Logo + promo bar + selling point keywords
The Agent should automatically choose a solution according to the following priority:
Solution 1 (preferred):run_command + Python PIL
First test the environment:
python3 -c "from PIL import Image; print('ok')" 2>/dev/null || pip install Pillow -q
If available, use the following script to precisely overlay the Chinese Logo, promo bar, and selling point keywords:
from PIL import Image, ImageDraw, ImageFont
import os
CANVAS = 800
FONT_PATHS = [
'/System/Library/Fonts/PingFang.ttc', # macOS
'/usr/share/fonts/truetype/noto/NotoSansCJK-Regular.ttc', # Linux Noto
'/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc', # Linux Noto alt
'/usr/share/fonts/truetype/droid/DroidSansFallbackFull.ttf', # Linux Droid
'/usr/share/fonts/truetype/wqy/wqy-zenhei.ttc', # Linux 文泉驿
]
def get_font(size, bold=False):
for fp in FONT_PATHS:
if os.path.exists(fp):
try:
idx = 1 if bold and fp.endswith('.ttc') else 0
return ImageFont.truetype(fp, size, index=idx)
except:
try: return ImageFont.truetype(fp, size, index=0)
except: continue
return ImageFont.load_default()
def add_overlay(img_path, output_path, logo_text,
promos=None, keywords=None,
tag_text=None, tag_sub='店铺折扣叠加官方立减'):
"""
promos: 活动列表, e.g. ['1件9折', '3件85折'] — 支持 1-N 条
keywords: 卖点关键词, e.g. ['加绒', '保暖'] — 左侧竖排显示
tag_text: 标签文字, e.g. '秋冬上新' — 为 None 时根据当前月份自动判断
"""
img = Image.open(img_path).convert('RGBA')
ratio = max(CANVAS / img.width, CANVAS / img.height)
img = img.resize((int(img.width * ratio), int(img.height * ratio)), Image.LANCZOS)
left = (img.width - CANVAS) // 2
img = img.crop((left, 0, left + CANVAS, CANVAS))
overlay = Image.new('RGBA', (CANVAS, CANVAS), (0, 0, 0, 0))
draw = ImageDraw.Draw(overlay)
# ===== Logo(左上角 + 阴影)=====
lf = get_font(32, bold=True)
for dx, dy in [(2,2),(1,1)]:
draw.text((24+dx, 20+dy), logo_text, fill=(0,0,0,80), font=lf)
draw.text((24, 20), logo_text, fill=(255,255,255,250), font=lf)
# ===== 卖点关键词(左侧竖排)=====
if keywords:
kf = get_font(36, bold=True)
total_h = len(keywords) * 50
ky = (CANVAS - total_h) // 2 - 40
for kw in keywords:
bb = draw.textbbox((0,0), kw, font=kf)
kw_w = bb[2] - bb[0]
draw.rounded_rectangle([16, ky-4, 16+kw_w+24, ky+42],
radius=6, fill=(0,0,0,100))
draw.text((29, ky+1), kw, fill=(0,0,0,60), font=kf)
draw.text((28, ky), kw, fill=(255,255,255,250), font=kf)
ky += 50
# ===== 底部活动条 =====
if promos:
# 自动判断季节标签
if tag_text is None:
import datetime
m = datetime.datetime.now().month
tag_text = {1:'年货节',2:'开春上新',3:'春季上新',4:'春季上新',
5:'初夏上新',6:'夏季上新',7:'夏季上新',8:'秋季上新',
9:'秋季上新',10:'秋冬上新',11:'秋冬上新',12:'年终大促'}.get(m,'新品上市')
h = 95; th = 32; y0 = CANVAS - h
# 过渡阴影
for i in range(30):
draw.rectangle([0, y0-30+i, CANVAS, y0-29+i], fill=(0,0,0,int(i*6)))
# 白色标签栏
draw.rectangle([0, y0, CANVAS, y0+th], fill=(255,255,255,250))
tf = get_font(14, bold=True)
tb = draw.textbbox((0,0), tag_text, font=tf)
tw = tb[2]-tb[0]+28
draw.rounded_rectangle([14, y0+4, 14+tw, y0+4+24], radius=5, fill=(56,161,105))
draw.text((28, y0+7), tag_text, fill='white', font=tf)
sf = get_font(12)
draw.text((14+tw+14, y0+9), tag_sub, fill=(170,170,170), font=sf)
# 红色主条(渐变)
my = y0 + th
for x in range(CANVAS):
r = min(int(210+20*x/CANVAS), 230)
draw.line([(x,my),(x,CANVAS)], fill=(r, min(int(50+8*x/CANVAS),58), 55))
# 活动文字(数字大 42px,文字小 22px,支持 N 条活动)
nf = get_font(42, bold=True)
xf = get_font(22, bold=True)
def measure(s):
return sum(draw.textbbox((0,0),c,font=nf if c.isdigit() else xf)[2]
-draw.textbbox((0,0),c,font=nf if c.isdigit() else xf)[0]+1 for c in s)
sep_w = 40
total_w = sum(measure(p) for p in promos) + sep_w * (len(promos) - 1)
sx = (CANVAS - total_w) // 2
cy = my + (CANVAS - my - 42) // 2
for idx, promo in enumerate(promos):
for c in promo:
f = nf if c.isdigit() else xf
yo = 0 if c.isdigit() else 16
bb = draw.textbbox((0,0), c, font=f)
draw.text((sx+1, cy+yo+1), c, fill=(0,0,0,40), font=f)
draw.text((sx, cy+yo), c, fill=(255,255,255), font=f)
sx += bb[2] - bb[0] + 1
if idx < len(promos) - 1:
sep_x = sx + sep_w // 2
draw.line([(sep_x, cy+6), (sep_x, cy+38)], fill=(255,255,255,100), width=2)
sx += sep_w
img = Image.alpha_composite(img, overlay)
img.convert('RGB').save(output_path, quality=95)
print(f'已生成: {output_path}')
Call example:
logo = '品牌名'
promos = ['1件9折', '3件85折'] # 支持 1-N 条
keywords = ['加绒', '保暖'] # 从商品描述提取
add_overlay('model1.png', 'carousel_01.jpg', logo, promos, keywords)
add_overlay('model2.png', 'carousel_02.jpg', logo, promos, keywords)
add_overlay('model3.png', 'carousel_03.jpg', logo, promos, keywords)
add_overlay('product.jpg', 'carousel_04.jpg', logo, promos, keywords)
add_overlay('product.jpg', 'carousel_05.jpg', logo) # 白底图,无活动条/卖点
⚠️ Delete intermediate artifacts after execution:
rm -f /tmp/product-details/overlay.py
Solution 2 (fallback):generate_image Generate directly
If run_command is unavailable, pass the model image into generate_image 's ImagePaths, and describe the overlay layout in the prompt. Chinese text may not be perfect but is acceptable.
Solution 3 (last resort):browser_subagent + HTML
Render precisely with HTML/CSS and then take a screenshot. The user will see the browser window, resulting in a poor experience; use only as a final fallback.
5 carousel image contents
- Model/scene front (Background A) + Logo + selling points + promo bar
- Model/scene side (Background B) + Logo + selling points + promo bar
- Model/scene another angle (Background C) + Logo + selling points + promo bar
- Product original image contextualized + Logo + selling points + promo bar
- Product close-up/white background image + Logo (no promo bar, no selling points)
Part 4: Detail image generation (9 images)
Layout planning
Choose 9 from the following types (adjust according to category):
| Priority | Type | Applicable category |
|---|---|---|
| ★★★ Required | Main image cover | All |
| ★★☆ Recommended | Core selling point image (2-3 images) | All |
| ★★☆ Recommended | Detail annotation image | All |
| ★★☆ Recommended | Usage scene/wearing scene | Apparel/Home/Food |
| ★★☆ Recommended | Specification parameter table | All |
| ★☆☆ Optional | Size Chart | Apparel/Footwear |
| ★☆☆ Optional | Packing List | 3C/Home/Gifts |
| ★☆☆ Optional | Comparison Image/Competitor Advantages | All |
| ★☆☆ Optional | Outfit Recommendations | Apparel |
| ★★☆ Recommended | After-Sales Guarantee | All |
Detail Image Generation Method
Use generate_image to generate one by one. Pass the user's original image as ImagePaths。
Prompt General Structure:
E-commerce product detail page image, 790px wide, approximately 1100px tall.
[Layout: what's shown, where elements are positioned]
[Chinese text content as decorative elements]
Product: [商品描述]
Style: [风格配色], professional Taobao/Tmall product detail page design.
9 Detail Image Prompt Templates
⚠️ The [占位符] in the following templates must be replaced according to the actual product!
1. Main Image Cover
E-commerce hero banner, 790x1100px.
Large product photo centered, product: [商品描述].
Top: large bold Chinese title "[标题2-6字]".
Subtitle: "[副标题一句话]".
Season tag: "[年份+季节]新款".
Style: [风格配色], premium e-commerce design.
2-4. Core Selling Point Images (one per selling point)
Product feature highlight page, 790x1100px.
[左右分栏/上下分栏] layout for: [商品描述].
Feature title: "[卖点标题]" in large bold text.
Description: "[卖点说明1-3行]".
[产品细节照片/图标插画] showing the feature.
Style: [风格配色].
5. Detail Annotation Image
Product detail annotation page, 790x1100px.
Center: full product photo of [商品描述].
4 annotation callouts with connecting lines:
- "[细节1]" pointing to [部位1]
- "[细节2]" pointing to [部位2]
- "[细节3]" pointing to [部位3]
- "[细节4]" pointing to [部位4]
Clean background, professional annotation style.
6. Usage Scene/Wearing Scene
Lifestyle scene page, 790x1100px.
Title: "[场景标题]".
[模特穿着/产品使用] photo in [场景描述].
Subtitle: "[副标题]".
Style: [风格配色], aspirational lifestyle design.
7. Specifications Table
Product specification page, 790x1100px, clean table layout.
Title: "产品参数".
Table rows:
品名: [商品名]
[面料/材质]: [具体信息]
[适用人群]: [具体信息]
[颜色]: [具体信息]
[其他参数...]
Small product thumbnail below.
Style: [风格配色], clean grid.
8. Size/Specification Chart (Apparel/Footwear)
Size chart page, 790x1100px.
Title: "尺码参考".
Table: [根据品类自动生成合适的尺码范围和度量项]
Note: "因测量方式不同,尺寸可能有1-3cm误差".
Size guide illustration.
Style: warm, parent-friendly design.
⚠️ The size range should be automatically adjusted according to the product category:
- Children's Clothing: 110-160
- Adult Men's Clothing: S/M/L/XL/2XL/3XL
- Adult Women's Clothing: XS/S/M/L/XL/2XL
- Footwear: 36-45 (or corresponding sizes)
- For non-apparel categories, skip this image and replace it with "Packing List" or "Comparison Advantages"
9. After-Sales Guarantee
After-sales guarantee page, 790x1100px.
Title: "售后保障".
4 guarantee icons in 2x2 grid:
- 正品保证(shield icon)
- 7天无理由退换(return icon)
- 极速退款(refund icon)
- 运费险(shipping icon)
Bottom: "品质之选 · 放心购买".
Style: trustworthy, warm, [风格配色].
Output Specifications
File Save Path
Save all generated images to /tmp/product-details/:
| Image Type | File Name |
|---|---|
| Model/Scene Original Image | model1.png, model2.png, model3.png |
| Carousel Finished Image | carousel_01.jpg ~ carousel_05.jpg |
| Detail Image | detail_01.png ~ detail_09.png |
| User Original Image Copy | product.jpg |
Display Method
Use view_file to display all images directly in the conversation:
- First display 5 carousel images
- Then display 9 detail images
- Finally provide a summary table of the image list
Error Handling
| Scenario | Handling Method |
|---|---|
generate_image The generated image does not meet expectations |
Adjust the prompt and regenerate, retry at most 2 times |
| PIL unavailable | Automatically downgrade to generate_image solution |
| User's original image resolution is too low | Notify the user, but continue generating |
| generate_image call failed | Skip that image, continue generating the remaining images, and inform the user at the end |
Notes
| ✅ Correct | ❌ Incorrect |
|---|---|
generate_image Pass the user's original image as ImagePaths |
Not passing the original image causes product appearance deviation |
| All Chinese copy is automatically generated by AI based on product analysis | Require the user to write the copy themselves |
| Model/scene images have a sense of scene in the background | Pure white or pure gray background |
| Output images directly in the conversation | Make the user manually export from the web page |
| PIL preferred, generate_image as fallback | Hard dependency on a single solution without fallback |
| All images have a consistent style | Each image has a different style |
| Adjust composition/size/scene according to the category | All products use the same template |
| Selling point keywords are automatically extracted from the description | Omit the core selling points in the user description |
| tag_text is automatically generated according to the season | Hardcode "Autumn/Winter New Arrivals" |