How it works

No magic, and no third-party service: the whole pipeline runs on this server.

1 · Clean up

The photo is decoded, turned the right way up from its EXIF orientation and scaled to a working resolution. An edge-preserving filter flattens sensor grain without softening eyelashes, and a median pass removes the isolated specks a scanner leaves on an old print.

2 · Learn the background

Colours are clustered in CIE L*a*b* — the space where distance matches what your eye calls "a different colour". The backdrop model is sampled from the top and upper sides of the frame, never the bottom, because that is where shoulders live. A subject model is taken from the centre. Anything you click is worth far more than a sampled pixel.

3 · Find the edge

Each pixel is scored against both models, then the score is diffused across low-contrast neighbours only, so the boundary settles onto real image edges instead of colour noise. In the narrow band around the silhouette, alpha is solved from the colour-line assumption and refined again at full resolution, which is what keeps stray hair.

4 · Unmix and recolour

Semi-transparent edge pixels still carry the old background's colour. They are unmixed before the new background goes in, so a green wall does not leave a green rim around the hair.

5 · Measure the head, then frame it

Passport rules are written as a chin-to-crown height in millimetres. The silhouette is read as a width-per-row profile: the head widens at the ears, pinches at the neck and flares at the shoulders. That gives the head box, a skin-tone pass refines the chin, and the crop is scaled so the head lands inside the published range with the correct margin above it.

Using a neural matting model

The built-in engine needs no model file and no network. If you want the edge quality of a trained portrait matting network, drop an ONNX model (U²-Net, IS-Net / RMBG or MODNet) into the application's Models folder and point Matting:Neural:ModelPath at it in appsettings.json. The studio picks it up on the next start and falls back to the built-in engine if it ever fails.

An unexpected error has occurred. Reload 🗙