Pixel-Clean Transparent Cutouts
Produce a transparent PNG that remains visually clean under high magnification and on both light and dark backgrounds. Preserve the subject's identity, proportions, internal details, colors, and canvas size unless the user asks for a change.
Required result
- Make every pixel outside the intended subject fully transparent.
- Remove source-background blocks, matte-colored fringes, peripheral ghosts, and unwanted cast shadows.
- Keep only a narrow, smooth antialiased transition at the true subject boundary.
- Store fully transparent pixels as transparent black (
RGBA 0,0,0,0) to avoid hidden matte colors. - Do not crop, reshape, repaint, or regenerate the subject merely to simplify extraction.
Treat a clean-looking thumbnail as insufficient evidence. The output is complete only after pixel-level verification.
Extraction strategy
Prefer deterministic masking for existing UI graphics and icons because it preserves the original asset exactly. Use generative image editing only when the boundary is genuinely missing or ambiguous, or when the user explicitly requests recreation.
Choose the mask from the asset's structure:
- For circles, ellipses, rounded rectangles, and other regular icons, reconstruct an analytic shape mask with supersampled coverage.
- For irregular subjects, derive a foreground mask using border-connected background detection, color or luminance separation, and connected-component cleanup.
- Preserve enclosed light regions only when they are genuine subject details. If a light region matches the external background and forms a designed gap between separate components, keep it transparent.
- Exclude decorative ground shadows unless the user explicitly asks to retain them.
For layered regular icons, derive alpha from the intended component topology rather than filling the outermost silhouette. Model disks, outline rings, connector strokes, text, and other pieces separately, then union only those pieces. Preserve transparent holes and gaps between concentric elements; do not turn them into opaque white or ivory plates merely because they are enclosed.
Fit regular geometry independently for every source image. Do not reuse one center, radius, bounding box, or aspect ratio across a batch unless direct inspection confirms that the geometry is identical. A shape intended as a circle must remain circular after extraction; pale halos, shadows, or background-colored regions must not pull the fitted boundary into an ellipse.
Do not solve edge contamination by changing alpha alone. Source edge pixels are often pre-composited with an ivory or white background. Decontaminate their RGB values by unmatting against the measured background or by sampling clean subject color a few pixels inward. For regular shapes, rebuilding the outer edge and sampling inward is usually more reliable than retaining the source rim.
For circular or elliptical badges, use scripts/rebuild-ellipse-cutout.ps1 as a deterministic option. Estimate the center and radii from the true colored body, not from its shadow or pale halo.
Source integrity and repair
Before masking, inspect the source at high magnification for broken outlines, missing contour segments, malformed joins, isolated missing pixels, and geometry clipped by the canvas. Thin strokes and regular shapes require particular attention because damage can look like background after extraction.
- Treat a gap as damage only when the intact geometry, symmetry, repeated structure, or user instruction makes the intended continuation clear. Preserve deliberate dashes, openings, cutouts, and asymmetry.
- When repair is requested or the damage is unambiguous and minor, reconstruct only the affected geometry from intact evidence. Fit regular contours analytically, extend compatible strokes, or mirror a genuinely symmetric segment while preserving the subject's identity, scale, position, proportions, stroke width, and color.
- If the intended contour is ambiguous or repair would amount to redesigning the subject, do not guess. Preserve the uncertain area and tell the user what cannot be inferred safely.
- If the source contour is clipped by the canvas and repair is authorized, restore it within the original canvas using the smallest positional adjustment that produces a complete boundary. Do not resize or recenter the whole subject unnecessarily.
- Build repaired edges with supersampled coverage and clean subject RGB rather than copying background-contaminated edge pixels. Verify the repaired candidate before replacing the destination.
Verification gate
For every output file, run scripts/make-alpha-diagnostic.ps1, then visually inspect the generated diagnostic. It shows the cutout at 8x nearest-neighbor scale on dark and light backgrounds beside its alpha channel.
Inspect the complete perimeter, especially the bottom edge where cast shadows and pale blocks commonly survive. Reject and revise the output if any of these remain:
- white, ivory, gray, or source-background-colored fringe;
- brown or colored peripheral ghost outside the subject;
- detached or semi-transparent shadow islands;
- broad fuzzy alpha bands;
- clipped subject pixels, jagged geometry, or accidental holes.
- unrepaired breaks or missing contour segments that are clearly inconsistent with the intended geometry;
- unintended bridges, closed gaps, or symmetry changes introduced by the repair.
- opaque white or ivory pixels filling an intended transparent hole or gap between components;
- a regular circle distorted into an ellipse, or batch items forced onto a shared center that does not match each source.
Also verify that the file is a 32-bit PNG with alpha, its dimensions match the source unless requested otherwise, its alpha bounds contain only the subject, and pixels outside those bounds are fully transparent. Check the final asset itself, not only an intermediate preview.
When the subject contains legitimate white details, add a targeted pixel check for bright low-saturation pixels outside those known detail regions. A nonzero count is evidence of residual background even when the thumbnail looks clean. Inspect the alpha topology as well as the RGB preview: intended holes must be black in the alpha panel, not white.
For batches, apply the verification gate and geometry fit to every file. Do not infer that the rest are clean or geometrically aligned because one example passed.
Delivery
Replace the requested destination only after the high-zoom diagnostic passes. Report the output path and briefly state that the transparent edge, residual background, and unwanted shadow were checked. If a clean extraction would require cutting into the subject, preserve the subject and tell the user what remains ambiguous instead of silently damaging it.