Most product-photo pipelines are tuned on a white background, because that is what marketplaces ask for. White is also the most forgiving background a cutout can be tested on. Every mistake a matte makes — a contaminated edge, a one-pixel ring of the old background, a bite taken out of a hair strand — disappears against white and reappears the moment the same PNG lands on a dark card, a coloured hero, or a comparison table.
That is not a rendering bug. It is what the file actually contains.
A cutout is a per-pixel mix, not a pair of layers
A straight-alpha PNG stores colour and opacity separately. An edge pixel is usually the original photo pixel — background included — with partial alpha. When the viewer composites it:
out = src * a + dst * (1 - a) the leftover background colour in src is multiplied by whatever a happens to be. Against white, that residue is white on white: invisible. Against #101010 it is a light rim. The alpha value was never wrong; the colour under it was.
Measure it with two composites
Composite the same RGBA image over white and over a near-black, then compare only the pixels whose alpha is strictly between 0 and 250 — the edge band. Fully opaque pixels and fully transparent pixels are identical in both composites by definition, so they contribute nothing but noise.
I ran it on a synthetic 600×600 test image: a blurred bottle shape with 120 one-pixel hair strands, a cream background, and two candidate mattes — one soft (1 px erosion plus a small blur, roughly what an over-eager segmentation threshold produces) and one hard (a 128 threshold, no partial alpha at all).
| Metric | Soft matte | Hard matte |
|---|---|---|
| Edge-band pixels (0 < a < 250) | 3,986 (1.11% of canvas) | 0 |
| Mean max-channel delta, white vs dark composite | 131.1 / 255 | — |
| Edge pixels reading light on white (all channels > 170) | 54.9% | — |
| Non-opaque pixels enclosed by the subject | 0 | 0 |
| Subject margins (L, T, R, B) | 180, 90, 179, 129 | 181, 91, 180, 130 |
The soft matte changes colour by more than half its range depending on what sits behind it — that is the fringe, quantified. Fifty-five percent of its edge pixels read light on white, which tells you the residue is concentrated in the background's colour: exactly the failure the dark composite exposes.
The hard matte scores zero on both, and that is not a win. It removed the partial-alpha band by deleting it, which is also how the hair strands disappear and the silhouette turns into a staircase. A clean threshold looks perfect on paper and worse on screen.
The script
from collections import deque from PIL import Image def audit(cutout_path, dark=(16, 16, 16), opaque=250): img = Image.open(cutout_path).convert("RGBA") w, h = img.size px = img.load() alpha = img.getchannel("A") band = light = 0 total_delta = 0.0 for y in range(h): for x in range(w): r, g, b, a = px[x, y] if 0 < a < opaque: band += 1 aw = a / 255.0 on_w = [c * aw + 255 * (1 - aw) for c in (r, g, b)] on_d = [c * aw + dark[i] * (1 - aw) for i, c in enumerate((r, g, b))] total_delta += max(abs(on_w[i] - on_d[i]) for i in range(3)) if min(on_w) > 170: light += 1 # exterior = non-opaque pixels reachable from the border outside = bytearray(w * h) q = deque() for x in range(w): for y in (0, h - 1): if alpha.getpixel((x, y)) < opaque and not outside[y * w + x]: outside[y * w + x] = 1; q.append((x, y)) for y in range(h): for x in (0, w - 1): if alpha.getpixel((x, y)) < opaque and not outside[y * w + x]: outside[y * w + x] = 1; q.append((x, y)) while q: x, y = q.popleft() for dx, dy in ((1, 0), (-1, 0), (0, 1), (0, -1)): nx, ny = x + dx, y + dy if 0 <= nx < w and 0 <= ny < h and not outside[ny * w + nx] and alpha.getpixel((nx, ny)) < opaque: outside[ny * w + nx] = 1; q.append((nx, ny)) holes = sum(1 for y in range(h) for x in range(w) if alpha.getpixel((x, y)) < opaque and not outside[y * w + x]) bbox = alpha.point(lambda v: 255 if v > 8 else 0).getbbox() margins = (bbox[0], bbox[1], w - bbox[2], h - bbox[3]) if bbox else None return { "edge_band_px": band, "edge_band_share": round(100 * band / (w * h), 3), "mean_edge_delta": round(total_delta / band, 1) if band else 0, "light_fringe_share": round(100 * light / band, 1) if band else 0, "enclosed_nonopaque_px": holes, "subject_margins": margins, } On a 2,000 px image, run it on a downscaled copy or move the loop to numpy; the shape of the numbers does not change.
Reading the numbers
- Mean edge delta above ~60/255 — the edge still carries the old background and will fringe on any non-white surface. Matte harder, or decontaminate the edge colour.
- Light fringe above ~30% of the band — the residue is biased toward a bright background. That is the signature of a matte grown a pixel or two past the subject.
- Any enclosed non-opaque pixel — a hole. I punched a 40×30 rectangle through the bottle in the test image and the check reported 1,271 pixels. Real holes are hair, wire, transparent packaging, or a shadow the model decided was background.
- A zero or near-zero margin — the subject touches the canvas. Marketplaces that re-crop to a square will cut the product, and the "white background" check can then fail on the crop rather than on the colour.
Why this is not the model's job
We do ask for clean edges: our edit prompt says "clean, precise edges with no halo or fringe", keeps every flyaway hair strand, and forbids reshaping the subject. Prompts are requests, not measurements. A generative edit can honour the instruction and still return a one-pixel white rim, because the rim is not something the request can see. The audit is what makes the claim checkable — run it on every output and hold the pipeline to the number.
What to deliver, once the edge is clean
Bake the decision into the export so the fringe cannot come back downstream:
| Destination | Deliver | Why |
|---|---|---|
| White-background marketplace | JPEG, background baked to #FFFFFF | No alpha survives the upload; a baked white edge cannot fringe |
| Design tool, mockup, coloured card | PNG with straight alpha, decontaminated edge | Transparency is the point; the edge must hold on any colour |
| Print or dark packaging | PNG, or TIFF with alpha | Dark substrates are where residue shows first |
A cutout is not finished when it looks right on white. It is finished when the edge band has nothing left to reveal on black — and that is a measurement, not an opinion.
I build CleanWhiteBG, a browser-based background remover for product photos: transparent cutouts, white marketplace exports, and batches of up to 50 images. The audit above is the check I run on its output before I trust it.

