← Back to context

Comment by adamhowell

2 hours ago

Claude and I have spent most of the summer on exactly this problem for Skechworks (skechworks.com), a free little Mac design app I made to help my own workflow that is very similar to yours. I use it for my custom coin shop The Achieve Mint (theachievemint.com).

It runs VTracer under the hood too. Most of the cleanup you're doing in Inkscape could possibly be pushed to before and after the trace?

Skechworks picks the palette before the trace and forces it again after. I quantize to 8 colors with pngquant, trace, then snap every fill back to the nearest palette color. VTracer fills each region with its own average color, otherwise you get hundreds of nearly identical grays. One design went from 279 fill colors to 3.

I upscale 2x before I quantize. The anti-aliasing is what tells the tracer where an edge really sits. Quantize at 1x and you throw that away, and small text comes out lumpy. Related gotcha: filter_speckle is an area, so don't double it when you double the image.

I also flatten transparency onto white first. VTracer counts every alpha value as a different color. I had a 5 color picture that it saw as 688 colors, and the trace took 6 GB of memory. Flattened, the same picture took 300 MB.

For the background I sample the whole edge of the picture. If 85% of it is one color, I delete every path in that color that touches the edge. White inside the drawing never touches the edge, so it stays.

For black and white I threshold with Otsu, then trace in color mode with hierarchical stacked instead of bw mode. bw mode hands you one giant black path full of holes. Stacked gives you every region as its own shape, which is much easier to edit. You have to pad the image with the background color first, or VTracer decides your subject is the canvas.

Your FLUX step is the same trick I use for photos and messy art. I have an image model redraw the picture as flat art, then trace the redraw. That came out about a quarter the file size of the best direct trace I could get. The catch is that the model moves and resizes the subject a little every run. I measure the box around the ink in both pictures and fit the trace back onto the original.

What I haven't solved is curve fitting. vectorizer.ai gives you real arcs and straight lines. VTracer gives you splines, so circles are never quite circles.