Fix Pasted-On AI Product Cutouts, White Edge Halos & Floating Shadows
Visual symptom: a transparent product cutout dropped onto a lifestyle background looks like a flat paper sticker—wrong highlight angle, bright edge rim, and zero grounded contact shadow You strip the studio background off a product photo and drop the transparent PNG onto a sunlit travertine table or moody slate backdrop. Even though the silhouette edges are clean, the item floats awkwardly with mismatched white reflections and flat artificial drop shadows.
Background removal only deletes pixels outside the object boundary; it preserves the original white-box studio lighting, neutral color bounce, and bright edge-pixel spill baked into the product’s pixels. Without color-decontaminated matting and physically consistent directional relighting, human eyes spot a fake composite within 200 milliseconds.
Copy-Paste Verified Fix
#!/usr/bin/env bash
set -euo pipefail
# Requires: FAL_KEY, curl, jq
# Total API cost: $0.018 (Bria RMBG 2.0) + $0.10 (IC-Light V2 1MP) = ~$0.12
RAW_URL="${1:?Pass raw studio product photo URL}"
LIGHT_SIDE="${2:-Left}" # Left | Right | Top | Bottom
SCENE_PROMPT="${3:-Product resting naturally on warm honed travertine stone plinth, crisp morning sunlight raking from frame left, grounded contact shadow falling to the right, warm soft studio fill, photoreal commercial packshot}"
echo "[1/2] Removing background via Bria RMBG 2.0 ($0.018, 100% licensed)..."
CUTOUT_URL=$(curl -sS -X POST "https://fal.run/fal-ai/bria/background/remove" \
-H "Authorization: Key ${FAL_KEY:?Set FAL_KEY}" \
-H "Content-Type: application/json" \
-d "{\"image_url\":\"${RAW_URL}\"}" | jq -r '.image.url // empty')
if [ -z "${CUTOUT_URL}" ]; then echo "Bria cutout failed" >&2; exit 1; fi
curl -fsSL "${CUTOUT_URL}" -o product_cutout_rgba.png
echo "[2/2] Relighting & grounding shadows via IC-Light V2 ($0.10/MP, bias=${LIGHT_SIDE})..."
RELIT_URL=$(curl -sS -X POST "https://fal.run/fal-ai/iclight-v2" \
-H "Authorization: Key ${FAL_KEY}" \
-H "Content-Type: application/json" \
-d "{
\"image_url\": \"${CUTOUT_URL}\",
\"prompt\": \"${SCENE_PROMPT}\",
\"initial_latent\": \"${LIGHT_SIDE}\",
\"image_size\": \"square_hd\",
\"enable_hr_fix\": true,
\"output_format\": \"png\",
\"seed\": 2048
}" | jq -r '.images[0].url // empty')
if [ -z "${RELIT_URL}" ]; then echo "IC-Light V2 relight failed" >&2; exit 1; fi
curl -fsSL "${RELIT_URL}" -o product_relit_hero_1024.png
echo "Done! Saved product_cutout_rgba.png + product_relit_hero_1024.png" Before vs. After (Broken Pattern vs. Verified Fix)
1. Basic cutout off bright white studio table -> white 2px fringe halo on dark edges
2. Paste onto warm golden-hour travertine kitchen backdrop
3. Add 40% opacity black oval shadow underneath
Result: Cold blue-white studio reflections clash with warm amber room; bottle floats visually. 1. fal-ai/bria/background/remove ($0.018) OR fal-ai/birefnet/v2 (refine_foreground: true)
2. fal-ai/iclight-v2 ($0.10 @ 1024x1024):
- initial_latent: "Left" (matches sunlit window on frame left)
- prompt: "luxury glass serum bottle resting on warm travertine stone, soft golden morning sunlight from frame left casting crisp contact shadow to the right, warm amber light bounce"
- enable_hr_fix: true
3. Optional: overlay sharp physical 6pt label crop + Topaz Image API 24MP ($0.08). Why this works: Decontaminating alpha edges removes chalky white halos, while IC-Light V2 physically recalculates glass speculars, warm stone bounce light, and directional contact shadows in one coherent pass.
Why This Failure Happens in Real Pipelines
Two distinct optical signals tell the human visual cortex whether an object actually sat in a room: edge color contamination and light-transport consistency. When a bottle or sneaker is photographed against a white seamless paper sweep, semi-transparent boundary pixels blend dark product pigment with bright white backdrop light. Dropping that raw cutout onto a warm timber or dark slate background creates a razor-thin chalky halo around the entire perimeter.
Even after decontaminating edge pixels (via BiRefNet v2 refine_foreground: true or clean Bria RMBG 2.0 alpha), the product still carries flat white-box lighting on its curved body while the background scene is lit by warm afternoon sun from the left. Adding a generic soft black Gaussian ellipse underneath in Photoshop never adds golden rim light to the glass shoulder or colored tabletop reflection under the base.
Running a clean 2-step compositing chain solves both defects deterministically: extract a halo-free foreground via Bria RMBG 2.0 ($0.018, 100% licensed) or BiRefNet v2 (MIT, refine_foreground: true), then pass that RGBA foreground into IC-Light V2 (fal-ai/iclight-v2, $0.10/MP) with initial_latent pinned to the exact light direction (Left, Right, Top, or Bottom) of your target scene. Finally, for fine 6pt packaging text, mask-blend a sharp luminance-matched copy of the original label on top.
Step-by-Step Resolution & Verification
- 01
Start from a clean evenly lit product photograph
Photograph your SKU under soft diffused light rather than harsh direct sunlight so pre-existing shadows do not fight your new lighting direction.
- 02
Extract a color-decontaminated transparent RGBA cutout
Call Bria RMBG 2.0 ($0.018, 100% licensed) or BiRefNet v2 (MIT with refine_foreground: true) so zero white background bleed clings to edge pixels.
- 03
Relight with IC-Light V2 pinning initial_latent to the true light side
Pass Left, Right, Top, or Bottom inside initial_latent matching your prompt’s window/softbox position, with enable_hr_fix: true at 1MP ($0.10).
- 04
Protect fine print labels and finish at 24MP for print/zoom
Verify every label letter against the original product shot (overlaying a sharp luminance-matched label patch if 6pt text softened), then scale approved heroes via Topaz Image API ($0.08).
python3 -c "from PIL import Image; a=Image.open('product_cutout_rgba.png'); b=Image.open('product_relit_hero_1024.png'); print('Cutout:', a.size, a.mode, '| Relit:', b.size, b.mode)"
# Visual 3-point check on product_relit_hero_1024.png:
# 1. Dark contact occlusion line hugs directly underneath the product base (no air gap).
# 2. Specular highlight sits strictly on the chosen initial_latent side (Left/Right).
# 3. Zero bright white 1-2px fringe along dark product edges. Cutout: (1024, 1024) RGBA | Relit: (1024, 1024) RGB — crisp contact shadow grounded directly under product base with matched directional rim light. How to Prevent This Error From Recurring
Keep IC-Light V2 exploration passes at 1MP ($0.10)
Never relight at 4K directly ($0.80+ per test); nail light direction at 1024×1024 and run Topaz 24MP ($0.08) once on the final pick.
Match camera eye-level perspective between cutout and scene prompt
A bottle shot from straight overhead cannot rest convincingly on a low eye-level tabletop prompt—keep source photography level with the intended surface.
Audit glass and dark metal edges against dark backgrounds
Always zoom to 200% along the shadow side of dark products to confirm zero lingering white sweep pixels.
- Fix 69: Fix AI Virtual Staging Warped Windows, Altered Floors & MLS Rejections
- Fix 72: Fix FLUX LoRA Overfitting, Fried Colors & Cloned Background Bleed
- Fix 73: Fix AI Video Object Removal Ghost Smudges, Shadow Trails & Mask Bleed
- Fix 74: Fix Broken AI 3D Mesh Rigging Weights, Candy-Wrapper Arms & Non-Manifold Errors
Troubleshooting FAQs
- Why does a sharp transparent PNG still look fake when pasted onto a new scene?
- Because transparency removes background pixels without changing the light reflections and color temperature already painted onto the product. IC-Light V2 recalculates specular highlights, surface color bounce, and contact occlusion shadows to physically unify the foreground and background.
- Should I use Bria RMBG 2.0 or BiRefNet v2 before IC-Light V2?
- Use Bria RMBG 2.0 ($0.018/img) when you want 100%-licensed commercial provenance or need the $0.03 text prompt to isolate one object from a busy scene. Use BiRefNet v2 (MIT) for $0 local GPU batches or 2048px wispy hair and translucent glass.
- How do I keep tiny 6pt ingredient text legible after IC-Light V2 relighting?
- Keep enable_hr_fix: true and moderate denoise, then drop a tight masked crop of the original physical label on top in Photoshop or Affinity using Multiply/Luminosity blend so the new lighting gradient rides cleanly across 100% razor-sharp original typography.
- What if the product’s cast shadow falls on the wrong side of the frame?
- Explicitly set initial_latent to "Left" or "Right" matching where the sunlight or key softbox enters the scene—casting shadows automatically to the opposite side.