Avatar editor
Upload, crop to a square or a circle, resize, and compress to a byte budget. The exported file is WebP where the browser can write it and a fallback otherwise, with every trace of location metadata removed.
Try it
No photo to hand? A generated scene with a person in it works too.
Options
Framing
Smart framing scores detail, colour and skin tones to find the subject, instead of
assuming it is in the middle. Centre-cropping a portrait is how avatars lose the
top of a head.
The pipeline behind this page
A square crop around the subject, a high quality downscale and a gentle sharpen, then an encode that bisects on quality until the file fits the budget. The circular mask is applied to the pixels rather than drawn with CSS, so the exported file is genuinely round - which is also why a circular avatar falls back to PNG rather than JPEG: a format without an alpha channel would show the corners.
// Square crop around the subject, high quality downscale, gentle sharpen,// then compress until it fits the budget. Circular masks are a pixel// operation, so they survive the resize rather than being a CSS trick.var pipeline = ImagePipeline.Create() .AutoOrient() .SmartCrop(AspectRatio.Square) // finds the subject instead of assuming the centre .Resize(size, size, ResizeMode.Stretch) .Sharpen(amount: 0.25f);using var avatar = await pipeline.ExecuteAsync(source);if (circular) ApplyCircularMask(avatar);var encoded = await exporter.EncodeWithFallbackAsync( avatar, circular ? [ImageFormat.WebP, ImageFormat.Png] : [ImageFormat.WebP, ImageFormat.Jpeg], new ImageExportOptions { Quality = 0.9, MaxFileSize = budgetKb * 1024, MinQuality = 0.5, Metadata = MetadataPolicy.Remove, Background = Rgba32.White, });What to take from it
- Frame the subject, not the centre.
SmartCropis a heuristic, not face recognition; if you have a detector, pass its rectangle toSmartCrop.FindCropasmustInclude. - Budget in bytes, not quality.
MaxFileSizereports the quality it settled on, and throwsImageEncodeExceptionrather than handing back an oversized file when the target is impossible. - Remove metadata. An avatar is published to everyone;
MetadataPolicy.Removeis the default for a reason. See Metadata and privacy.