White-background product image → a textured, photo-realistic scene image. The product stays put; the environment is replaced.
The key is not "pasting on a background," butcontact shadows, environmental reflections, and consistent light direction—if these three things aren't achieved, the product looks like a sticker floating on the background.
Generation result example
| Input: product image |
|---|
product-shoes.jpg — Black crocodile-textured glossy leather brogue derby shoes, white background, 800×800 |
Command actually executed:
dlazy gpt-image-2 \
--prompt 'Place this product into a photorealistic lifestyle scene. Keep the pair of black patent leather derby shoes 100% faithful: same glossy patent finish, same brogue perforation pattern, same lacing, same chunky lug sole, same proportions and camera angle. Replace the plain background with a warm autumn scene: a weathered wooden floor beside a window, a few dry maple leaves, soft late-afternoon side light casting a natural contact shadow under each shoe, blurred indoor background. The shoes must sit believably on the surface with correct perspective and grounded shadows. Photorealistic commercial product photography, no text, no watermark.' \
--images docs/item-change-background/product-shoes.jpg \
--size 1024x1024 --quality medium --imageFormat jpeg \
--save docs/item-change-background/example-output.jpg
Output
example-output.jpg — 1024×1024. The shoes' crocodile embossing, brogue perforations, white welt stitching, and thick lugged soles remain unchanged; the background is replaced with old wooden planks by a window + maple leaves, afternoon side light creates highlights on the toe caps, each shoe has a contact shadow beneath it, and the warm tones of the wood grain are slightly reflected by the glossy leather.
1. Capability boundaries
| Method | Description |
|---|---|
| Text-to-background | Describe the target scene in text; the model generates the environment |
| Upload background | Provide a background image and composite the product into it |
| Capability | Description |
|---|---|
| Background templates | Smart recommendation / wooden stick clothes rack / light-colored wooden branch / custom |
| Product category | Helps determine a reasonable scene (shoes → ground, beauty → countertop, home goods → room) |
| Physically correct | Contact shadows, environmental reflections, and consistent light direction and color temperature |
What it won't do: It won't change the product's shape, color, material, or logo; won't add product parts that aren't in the original image; won't generate misleading usage scenarios (e.g., putting a non-waterproof product in water).
2. Input asset rules
Self-check these hard constraints before generating:
- Size:20KB ~ 15MB
- Resolution:greater than 400×400
- Format:jpg / jpeg / png / webp
Input recommendations
| Practice | Description |
|---|---|
| ✅ Pure white/solid-color background product image | Cleanest cutout edges |
| ✅ Product complete, main view | Parts extending beyond the frame will have to be fabricated after placement in the scene |
| ✅ Even lighting | If the original image has strong directional light, the new scene's light direction must match it |
| ❌ Already in a complex scene | First use clothing-extraction or cutout to clean it to a white background |
| ❌ Semi-transparent/reflective product with no reference | Glass bottles and mirrored products need environmental reflections to look real; a white-background image doesn't provide enough information |
3. Three physical constraints that make the product "land"
These three sentences almost determine success or failure; write them every time:
1. 接地:sitting believably on the surface with correct perspective and a grounded contact shadow
2. 光向:light direction and colour temperature must match the shading already on the product
3. 反光:[环境元素] subtly reflected on the [商品材质], consistent with the scene
Category → reasonable scene reference
| Category | Reasonable scene | Avoid |
|---|---|---|
| Shoes | Wood floor / stone slab path / steps, product in contact with the ground | Floating, placed on fabric with no indentation |
| Bags | Chair back / tabletop / handheld, with load-bearing deformation | standing rigidly in midair |
| Beauty | Marble countertop / velvet cloth / bathroom counter, with reflections | Placed on grass, outdoors |
| 3C | Wooden table / office desk / dark countertop, hard light rim | Cozy pastoral style |
| Home | Complete room perspective, proportions reasonable with furniture | Room with clearly wrong dimensions |
| Food | Dining table / kitchen countertop / bamboo mat, warm light | Cool-toned industrial style |
4. Tool invocation
This skill uses dLazy's gpt-image-2(image editing model; the difficulty of changing a product's background is "product pixels unchanged + environment reconstruction + physically correct light-shadow coupling," requiring strong region preservation and scene understanding).
How to invoke
Two equivalent ways to write it; choose one. The unified entry point automatically selects the backend, retries on failure, creates directories and saves to disk, and estimates cost:
# A. 统一入口(推荐):可切任意后端,加 --dry-run 不计费空跑
node scripts/gen.mjs --task item-change-background \
--prompt '<见下方 Prompt 模板>' \
--images <按下表顺序> \
--save output/item-change-background-<sku>.jpg
# B. 直接用 dLazy CLI(不想引入 Node 依赖时,效果等价)
dlazy gpt-image-2 --prompt '...' --images ... --save output/item-change-background.jpg
Parameter conventions (fixed usage for this skill)
| Parameter | Value | Reason |
|---|---|---|
--images |
[商品图](text-to-background) / [商品图, 背景图](upload background) |
The order is image 1 / 2 in the prompt |
--size |
1024x1024(square main image) / 1024x1536(vertical scene) |
Follow main image specifications |
--quality |
high(reflective materials such as leather, metal, glass) / medium(matte materials) |
Reflective materials rely on high |
--imageFormat |
jpeg |
General format |
--batch |
2 ~ 4 |
Large randomness in scene composition |
--save |
docs/item-change-background/output-<sku>-<场景>.jpg |
Archive by scene |
Command Examples
# basic call: 文生背景
dlazy gpt-image-2 \
--prompt 'Place this product into a photorealistic lifestyle scene. Keep the product 100% faithful: same shape, colour, material finish and logo. Replace the plain background with a weathered wooden floor beside a window, soft late-afternoon side light casting a natural contact shadow, blurred indoor background. The product must sit believably on the surface with correct perspective and grounded shadows. Photorealistic commercial product photography, no text.' \
--images docs/item-change-background/product-shoes.jpg \
--size 1024x1024 --quality medium
# complex call: 上传背景图 + 一个商品铺 4 个场景
SRC=docs/item-change-background/product-shoes.jpg
KEEP='Keep the pair of black crocodile-embossed patent leather derby shoes 100% faithful: same glossy finish, same croc embossing pattern, same brogue perforation, same lacing, same white welt stitching, same chunky lug sole, same proportions and camera angle.'
PHYS='The shoes must sit believably on the surface with correct perspective and a grounded contact shadow under each shoe. Light direction and colour temperature must match the shading already on the product. Photorealistic commercial product photography, no text, no watermark.'
for S in wood street office autumn; do
case $S in
wood) SCENE='on a weathered wooden floor beside a window, soft late-afternoon side light, blurred indoor background' ;;
street) SCENE='on wet grey cobblestones after rain, reflections in the puddles, overcast diffused light' ;;
office) SCENE='on a dark polished stone floor in a modern office lobby, cool directional light, glass panels blurred behind' ;;
autumn) SCENE='on a wooden deck with a few dry maple leaves, warm golden-hour side light' ;;
esac
dlazy gpt-image-2 \
--prompt "Place this product into a photorealistic lifestyle scene. $KEEP Replace the plain background with a scene: $SCENE. $PHYS" \
--images "$SRC" --size 1024x1024 --quality high --imageFormat jpeg \
--batch 2 --save "docs/item-change-background/output-sku001-$S.jpg"
done
# 上传背景图的写法:--images 商品图 背景图
dlazy gpt-image-2 \
--prompt 'Composite the product from image 1 into the scene from image 2. Keep the product 100% faithful. Place it on [具体位置] with correct perspective, a grounded contact shadow, and light direction matching image 2. Blend edges seamlessly; no cut-out halo. Photorealistic, no text.' \
--images docs/item-change-background/product-shoes.jpg docs/item-change-background/bg.jpg \
--size 1024x1024 --quality high
# 先估价不真跑
dlazy gpt-image-2 --dry-run --prompt '...' --images a.jpg --size 1024x1024 --quality high
Further reading
| What to look up | Where to go |
|---|---|
| Authentication, multi-backend configuration, output structure, error codes | references/provider-cli.md |
gpt-image-2 all available parameters |
references/model-flags.md |
| All options of the unified entry point | node scripts/gen.mjs --help |
5. Prompt template
Place this product into a photorealistic lifestyle scene.
Keep the [商品品类 + 颜色 + 材质] 100% faithful: same [外形], same [材质光泽],
same [五金/缝线/纹理], same [logo 位置], same proportions and camera angle.
Replace the background with [场景描述:表面 + 环境 + 道具 + 光线].
The product must sit believably on the surface with correct perspective and a
grounded contact shadow. Light direction and colour temperature must match the
shading already on the product. [环境元素] subtly reflected on the [材质].
Photorealistic commercial product photography, no text, no watermark.
Correction sentences appended by issue
| Issue | Append to the end of the prompt |
|---|---|
| Product looks like a sticker floating | Add a soft occlusion/contact shadow where the product meets the surface, and a faint ambient-occlusion darkening along the contact line. |
| Light direction doesn't match | The scene light must come from [方向], matching the highlight already on the product. |
| White edges in the cutout | Blend the product edges seamlessly into the scene; no cut-out halo, no white fringe. |
| Product was altered | Change only the background. Every pixel of the product must remain identical to image 1. |
| Reflective materials look fake | Render physically plausible reflections of the surrounding scene on the [材质] surface. |
| Product is too small | The product must occupy at least 45% of the frame and be the sharpest element. |
6. Execution workflow
- Cut to white background: If the product image has a complex background, cut it out cleanly first.
- Check category → reasonable scene(table in section 3), to avoid physically impossible combinations.
- Write product fidelity sentence → Write scene sentence → Write three physical constraints(grounding / light direction / reflections).
- For reflective materials use
--quality high。 --batch 2~4to generate multiple images and pick the composition, save to disk todocs/item-change-background/。- Quality check: whether it is grounded (whether there are shadows and indentations), whether the light direction is consistent, whether there are white edges, and whether the product itself has been altered.
7. Common issues
| Symptom | Cause | Handling |
|---|---|---|
| Product looks like it is floating on the background | Missing grounding shadow | Append grounding shadow + AO darkening sentence |
| Light direction clearly contradictory | Light direction not constrained | Append a sentence specifying the light direction, consistent with the product's original highlights |
| White edges around the border | Cutout residue | Append a no-white-edge blending sentence |
| Product details were altered | The model redrew the product | Append Change only the background. |
| Glass/metal reflections look very fake | Lacks environmental reflections | Append an environmental reflection sentence + --quality high |
| Unreasonable scene (shoes floating on grass) | Category does not match the scene | Check the table in Section 3 to change the scene |
Tips
Visit https://dlazy.com for more information.