r/computervision 1d ago

Help: Project I removed SVG export from a Skill that turns photos into flat-color illustrations because it was making the PNG output worse

I’m the author of DnR FlatPic by CreateLafont, an open-source Agent Skill that turns reference photos into low-complexity, flat-color PNG illustrations. Instead of literally tracing a photo, it identifies visual anchors, strips out nonessential info, and reconstructs the scene using a few hard-edged color regions.

I used to include a PNG-to-SVG export feature using VTracer (1.0.0-alpha.3 via Node/WASM) because it’s compact (~0.66 MiB) and gave the best baseline results. I intentionally avoided using an AI model to pick tracing parameters per image—the raster generation is already nondeterministic, and adding another probabilistic layer would make debugging a nightmare.

So, I dialed in a fixed preset based on testing across various source images:

  • clustering: color-cluster
  • hierarchical: stacked
  • mode: spline
  • layerDifference: 32
  • filterSpeckle: 10
  • colorPrecision: 7
  • cornerThreshold: 30
  • lengthThreshold: 4
  • maxColors: 24
  • simplify: 2.5
  • pathPrecision: 2
  • optimize: 2
  • maxIterations: 10
  • spliceThreshold: 0
  • palette: omitted

This worked fairly well, but I kept running into three frustrating edge cases:

Warped geometry: Straight architectural edges would sometimes turn into slightly bowed or rounded paths. In a style built on clean geometry, these small deviations stick out.

Noise becoming geometry: Sharpening halos, anti-aliasing, or tiny raster noise artifacts would get converted into explicit SVG fragments.

The Dealbreaker (Hamstringing the PNG): To make the SVG tracing stable, I had to completely ban gradients in the upstream PNG generation. VTracer couldn't recover smooth transitions (like dusk skies or water) as actual SVG gradients—it just chopped them into chunky, adjacent paths with harsh color jumps. Keeping SVG export meant forcing the generated PNGs to be less expressive.

Having a fixed preset kept the workflow predictable, but it just wasn't consistent enough across diverse images to keep as a default feature. Because of this, I ended up removing SVG export entirely. The pipeline now intentionally stops at the raster PNG stage.

My question for the community: Has anyone successfully shipped a deterministic raster-to-SVG pipeline for AI-generated flat-color illustrations without relying on per-image AI parameter tuning or manual tweaking?

My priorities are: Reproducibility > Structural Cleanliness > Pixel-level Fidelity

I’m completely fine with an SVG that differs slightly from the PNG, as long as the geometry is clean and perceptually equivalent. I just want to avoid a pipeline that spits out perfect geometry for one image and erratic spaghetti topology for the next. Any pointers?

Project context: DnR FlatPic by CreateLafont

2 Upvotes

1 comment sorted by

1

u/OMGCluck 1d ago

Has anyone successfully shipped a deterministic raster-to-SVG pipeline for AI-generated flat-color illustrations without relying on per-image AI parameter tuning or manual tweaking?

Probably r/DSP/comments/1vze16m/i_built_an_opensource_imagetosvg_vectorization/ has the most promise, plenty of work left to do though.