# XWUIImageToSvg

Convert a raster image (PNG, JPG, WebP) to SVG in the browser. Drop or pick a file, tune **Colors** (2–16), **Detail** (low / medium / high), **Smooth curves** and **Remove background**, compare original and SVG side by side, then **Copy SVG** or **Download SVG**. The image is never uploaded.

Best on flat artwork: icons, logos, badges, illustrations with a handful of solid colours. Photos and smooth gradients trace into many stepped colour bands; redraw those by hand if you need a clean mark.

```ts
const converter = new XWUIImageToSvg(host, { colors: 6, detail: 'medium' });
converter.onConvert(({ svg, pathCount }) => console.log(pathCount, svg.length));
await converter.convertFile(file);   // or converter.convertImageData(ctx.getImageData(...))
```

The tracer is exported on its own for scripts and workers — no DOM needed:

```ts
import { traceToSvg } from '@exonware/xwui/basic';
const { svg, palette } = traceToSvg(imageData, { colors: 4, simplify: 1, smooth: true });
```

How it traces: k-means palette (seeded from the most common colours, so the same image always gives the same SVG) → pixel-edge loops per colour (`fill-rule="evenodd"`, holes included) → speck removal → Ramer–Douglas–Peucker simplification → gentle turns become quadratic curves, sharp corners stay sharp.
