Skip to content

Design notes

Why the non-obvious choices were made, what broke before, and the measurements behind them. Newest thinking is in the relevant docs; this is the record.

The tracers are classical, not a model. The research in research found that no downloadable AI model beats a good classical tracer at the tracing itself: VTracer matches or beats every learned model on icons and clearly beats them on illustrations, at a fraction of a second instead of 10–80 seconds on a GPU. AI belongs around the tracer (background removal, upscaling), which is the next phase.

VTracer was vendored with a rewritten loader, until #53. The official @visioncortex/vtracer package is a wasm-pack --target nodejs build: the wasm is portable, but the glue reads it with fs.readFileSync, so it cannot load in a browser. The community browser build wraps the older 0.8 engine and misses 1.0’s palette and simplification options, so a script rewrote the glue to ESM with an async init(url), asserting every substitution matched. Once Inlay took Poster too, the app stopped shipping VTracer; it’s now a benchmark only, loaded in Node as published (scripts/vtracer.mjs).

Flat art traces each edge once. VTracer traces every color region on its own and smooths the pixel outline into curves without knowing where the corners are. On the sample badge that turned the straight mountain slopes into slow S-bends and the snow-cap peaks into rounded bumps with two nodes a pixel apart, and none of its settings gave straight lines and sharp corners. Fitting each traced shape separately fixed the lines but opened hairline gaps, because cut-out shapes trace every shared edge twice and the two copies were fitted a fraction of a pixel apart. So Logo, Illustration and Line art now use a tracer of our own, Inlay (packages/inlay/src/inlay.ts), named for inlaid wood, where every piece is cut to fit its neighbors:

  1. Label every pixel with a palette color (the histogram peaks below). A pixel between two colors (anti-aliasing) takes the nearest color among its neighbors, so a red/blue edge never grows a purple sliver.
  2. Merge specks into their surroundings.
  3. Walk the cracks between differently labeled pixels. Where three regions meet is a junction; each boundary between junctions is one chain, with one region either side.
  4. Fit each chain once (packages/inlay/src/fit.ts): find corners (two straight sides, fitted a few pixels out, that meet near the outline; a round end’s sides run parallel, so it stays a curve), then a straight line wherever one fits within 1.5× tolerance, otherwise straight stretches as lines and the rest as least-squares Béziers (Schneider) with matching tangents. The line test sees a plain moving average, which removes JPEG’s 16 px color-block ripple; curves see an average whose window shrinks with local curvature, so small dots keep their size.
  5. Build each region from its chains. Neighbors share the same fitted edge exactly: no gaps, no overlaps, which is also what a vinyl cutter wants.

Scored with npm run score (rendered back at 4× against the clean art, where wobble and rounded corners count):

Sample badge Wrong pixels at 4× Nodes Size
VTracer, previous Logo settings 0.86% 259 7.3 KB
Shared edges, fitted per chain 0.74% 167 5.0 KB
+ corners by their sides, round ends, lines inside curves 0.70% 177 5.4 KB
+ exact shapes (#37) 0.54% 175 5.4 KB

(Re-measured later for the landing page, VTracer comes out at 0.85% and 271 nodes; see measuring quality.)

Straight edges are single segments and the peaks are single sharp corners.

The third row came from Matt’s testing on a different browser, whose JPEG encoder left different noise: a bump at a snow cap’s tip and hooked ends on the sample’s arc. Sweeping JPEG quality reproduced both, and the fixes were about telling shapes apart rather than tuning numbers. A corner is now two straight sides meeting near the outline (a stroke’s 4 px round end has sides that run parallel, so it stays a curve); smoothing follows local curvature, measured at two scales so JPEG noise can’t fake a tight bend; runs that mix straight and curved parts get lines for the straight stretches and curves joined smoothly between them; and a curve turns at most about 90°, so a circle is four curves. The extra nodes are those round ends and circles. On a 2048 px image Inlay took 1.3 s where VTracer took 17.5 s.

Pixel art moved to Inlay too. Pixel art wants its exact staircase, which Inlay already walks before it fits anything, so a pixel mode skips the clean-up and the fitting and joins straight runs. Its palette is the image’s exact colors, because histogram peaks drop a one-pixel eye for being rare and fold close shades together. On a test sprite both engines draw every pixel exactly; Inlay uses 14% fewer nodes, about the same bytes, and on a 1024 px sprite is 4× faster (0.2 s against 0.85 s). That left Poster on VTracer, since photos have no flat regions or histogram peaks and cut-out shapes cost size there, until #53 (below).

Tuning the presets. Each candidate setting was scored by tracing, rendering the SVG back in Chromium, and measuring the error against the clean source art, not the JPEG. On the built-in sample badge (5 colors, JPEG at q72):

Change Wrong pixels Paths Size
Color cap 6 (first attempt) 8.75% 346 68 KB
Cap 8 1.39% 373 70 KB
+ layerDifference: 32, speckle 8 1.50% 45 13 KB
+ cut-out shapes 0.95% 15 7 KB
+ palette from histogram peaks 0.93% (mean error 3.28 → 1.47) 14 4.3 KB

Two of those were surprises worth remembering:

  • A cap equal to the number of colors is too low. Anti-aliased edge shades take quantizer slots, so with a cap of 6 on a 5-color badge the red mountain and green hill merged into one brown. The color hint in the UI says to raise the cap if that happens.
  • VTracer’s quantizer drifts flat colors towards their neighbors. The gold sun came out pale peach, plainly visible in the Difference view. Flat art’s real colors are sharp peaks in the histogram, with anti-aliasing a thin spread between them, so packages/inlay/src/palette.ts takes the peaks (5-bit bins, most frequent first, accepted only if perceptually distinct in OKLab) and passed them to VTracer as a fixed palette (Inlay uses them the same way now). That recovered the source colors almost exactly, and on a real illustration cut mean error from 11.1 to 4.3. On a photo it made things worse (9.9 → 15.3), since photos have no peaks, so Poster kept VTracer’s quantizer; it now uses Inlay’s own (quantizePalette).

layerDifference and cut-out shapes follow the same pattern: big wins on flat art, costs on photos, so they are per-preset rather than global.

Small images. A 146×156 logo has eye slits and teeth 2–3 px wide, and VTracer faithfully traces their pixel steps, so the result came out wobbly with the anti-aliasing as an extra gray ink. Sources under 512 px are now upscaled to 1024 px with smoothing and a blur of half the scale factor before tracing; the same logo then traced to clean curves with every detail intact. Mid-size images are left alone: the 640 px sample was already at 0.93% wrong pixels natively.

Light ink on dark. Line art always traces the dark side, so a white logo on black came out as the background with holes. Line art can now invert first (“Light on dark”), and starts that way when the image’s border is dark. On a white-on-black logo that is the whole job in one step: background gone, white shapes as black paths, 6.5 KB. Line art also defaults to one threshold for the whole image (a fixed 128 then, the image’s own Otsu split since “Outline illustrations” below); adaptive thresholding closed the thin gaps between the logo’s shapes, so it stays as an option (“Uneven light”) for photos of paper.

Outline illustrations. An error-page illustration (a sinking ship: 3 px mid-blue outlines on white, the ship and moon filled with pale blues, saved as lossy WebP) traced as almost nothing. Six separate causes, each now fixed:

  • Speck clean-up dissolved the strokes. Lossy compression smears a thin stroke into two shades of its ink (0.08 apart in OKLab, so both made the palette), and each fragment was a speck. A speck joined the label it shared most edge with, which for a piece of a 3 px stroke is the paper; and a speck whose neighbor had just joined its own color was still judged alone. Specks now join the neighbor nearest in color, and wait a pass once they’ve grown. Slivers under 2 px wide fold into a neighbor within 0.12 of their color (a hairline of a color of its own has none, so it stays), one at a time so two side by side don’t just swap. Poster kept the old clean-up (the photo option): on photos the new one kept so many real regions that files grew by half (203 → 310 KB on score:photos, though 22% closer). It has since taken a part of it: see “Poster’s outlines came out jagged” below.
  • Pale fills never made the palette. A light-blue fill is 0.03 from white, under the 0.07 that makes a color distinct, and on the line from white to the ink, so it read as an edge. Fills are flat (every pixel matches its four neighbors) and edges never are, so peakPalette now fills spare slots with flat tints at least 0.02 from the others, and drops a blend that is never flat at any share under 2% (the anti-aliasing of thin outlines on white is plentiful enough to pass minShare; above 2%, 1 px rules and dithered fills, never flat either, are real colors).
  • Line art’s fixed 128 sat on the ink. The blue’s luminance is 122, with noise either side. Line art and Centerline now default to the image’s own ink/paper split (Otsu, “Auto”); the fixed level is still there as “Manual”. On a blank, noisy page Otsu splits the paper itself, so when its two sides’ means are under 40 apart Auto falls back to 128. On the pen drawing it cost little (Line art 0.36% → 0.38% wrong, Centerline 0.83% → 0.90%).
  • A 3 px letter stem collapsed to a line. Its ends are too narrow to measure as corners, so both long sides were fitted between the same two nodes. A closed outline that loses over half its area is refitted as a smooth loop, or kept as its pixel outline.
  • Spikes under thin letters. A stem’s nearly parallel sides “met” 13 px past its last pixels, and a least-squares cubic put a handle 100 px out. A narrow corner must now lie within 0.5 / tan(θ/2) + 1 px of its pixels (where a real point thins below a pixel), and handles longer than their run fall back to a third of the chord.
  • Pixel art took the page for pixel art. 88% of the image was one exact white, so the exact palette “covered” it; the other 31 colors were near-whites and the drawing traced white. Coverage no longer counts the commonest color.

npm run score has the case as scripts/fixtures/outline.svg, scored wrong past 24 instead of 96 (a missing pale fill is under 96 from white): Logo went from 13.0% to 2.1% of pixels wrong, with the badge, emblems and photos unchanged.

Small text beside an illustration. The same page’s body text (gray letters of 1.5 px strokes, 10–40 px each) vanished in Logo and broke apart in Illustration, for three reasons, all in flat art only (Poster unchanged):

  • No pixel of a thin letter is sure of its gray. Each is a mix of gray and white, so each was “unsure” and took a sure neighbor’s color, and the only sure neighbors were white. An unsure pixel next to just one color isn’t an edge between two, so it now keeps its own.
  • Pale gray read as light blue. The palette has no light gray, and by plain OKLab distance a letter’s pale edge was nearer the light blue ink. An in-between pixel more than 0.05 from every palette color is now read as a mix of the two whose blend (in sRGB, as a renderer mixes) comes nearest it, and goes to the one it holds more of. (Not nearer than that: a pale blue fill lies on the line from white to the blue ink too, and read as a mix a pale “+” eroded to white.)
  • Every letter was a speck. Under Logo’s 64 px each one merged into the paper. A speck 0.25 or more from every color around it (gray on white is 0.47) is a shape, not noise, and stays, from an eighth of the speck size up (never under 6 px): a 2 × 2 dot still goes, and raising Speckle still clears text. Rings of a 1.5 px stroke hold at Speckle 8 and go at 30.

A gray fleck inside a blue letter, or the reverse, now folds smallest first, so the fleck joins the letter and not the letter the fleck. The ship’s text is legible at the default settings in both presets, at a cost in size (Logo 30 → 77 KB, nearly all of it the letters), and the moon’s small pale “+” and ring come out cleaner too. The outline fixture went from 2.1% to 2.0% wrong; the badge and emblems score the same (a few more nodes), and the pen drawing is unchanged.

Outline art: lines as strokes. Even traced well, an outline drawn as a 3 px line comes out as a thin filled ring whose two edges are fitted apart, so it wobbles in width, and it can’t be thinned, recolored as one line or moved off the fill. With strokes (the Outline art preset) the colors that are mostly lines are traced as Centerline traces ink, down the middle, sharing its skeleton code (skeleton.ts), and the shapes either side grow into the line’s pixels a step at a time so they meet under its middle. What it took on the sinking ship, and in review:

  • Thin parts, not thin regions. A 3-4 chamfer distance finds everything deeper than an 8 px line; those discs are cut away, and what remains of each region is thin when it is at least three times as long as wide. Judging whole regions instead lost any outline that runs into a solid area of the same ink. A color is lines when it stands 0.25 (OKLab) from the paper (a pale fill squeezed between two lines is thin too) and 30% of it is thin. On a transparent background there is no paper color: the ink can be the commonest color there.
  • Lossy shades. The ship’s outline is two blues, the second darker in stretches, and short dashes come in halves of each. A line’s ink takes the thin parts of every color between the paper and it (or beyond, darker) within 0.15 of the blend, taken together, then grows into any touching pixel of such a color, its anti-aliased edges included, short of the solid areas cut away above. Gray text near blue lines doesn’t count: 0.3 off.
  • One width a color, measured a piece at a time. Each connected piece of ink gets its own width (area over skeleton length). Only pieces at least 2.5 px wide, eight times as long as wide and within 20% of the color’s usual (area-weighted median) width are drawn, at that width. At 1.5 px a letter’s skeleton is a few pixels between junctions and pruning ate stems (“h” came out as “n”); at five times as long, the heading’s “t” and “r” (the same blue as the outlines, 4–5 px) branched into wrong shapes. Short marks stay shapes too, which costs some of the saving. All the widths scale with scale when the image was enlarged for tracing.

On the outline fixture Outline art scores 2.06% wrong against Illustration’s 2.01%, with 271 nodes against 359 and 6.9 KB against 9.9; the badge doesn’t change (it has no lines), and without strokes nothing does. It adds about 300 ms to an 800 × 600 trace.

Thin lines keep their ends. With npm run score counting line pieces (#144), a copy of the junction fixture with 2.2 px lines came out as 11 pieces for 8 in every outline preset, at the default settings and as JPEG: each arm of the T and the Y tapered to a point, which is how the sinking ship’s thin outlines looked broken. A T has one corner, under its bar, so each arm’s end is a 2 px turn in the middle of one long run. The fitter found each side of an arm as a straight stretch, and a gap under 4 px between two straight stretches is a stub to skip, so the second side started where the first ended: the two sides met at a point. A gap where the outline turns back on itself is the end of a line, not a stub, and is now fitted as a little cap. All 8 pieces come through in every preset (2.25% → 2.05% wrong); nothing else in the score moves beyond a node or two.

Strokes run straight through junctions. Zhang-Suen thinning, which Centerline and Outline art’s lines start from, pulls the skeleton toward each junction: on a copy of the junction fixture with 8 px lines, Centerline’s X pinched at its crossing, the two strokes bending 2.5 px off their lines to run together for a stroke’s width. The line-drawing papers (Noris et al. 2013 and later) re-trace each arm from outside the junction. Here, within a stroke width of a junction, each arm’s skeleton is dropped, its direction is measured just outside, and the arms are drawn straight on to the point nearest all their lines (least squares; the junction’s center if the arms are near parallel or that point is more than a stroke width away). The X now stays within a pixel of straight, and Centerline uses 43 nodes there instead of 55; the other fixtures lose a few nodes and score the same.

Slanted hairlines stay joined. A line about a pixel wide at a slant is a staircase of pixels that touch only at their corners, and Inlay’s regions are 4-connected, so each step was a speck of its own and speck clean-up erased it. That, not lost pixels, broke 1 px outlines: on the junction fixture at 1.1 px, Logo made 25 pieces of 8 and Line art 16. Wherever two pixels of a label touch only at a corner across two of another (a 2 × 2 checkerboard), one of the two corner pixels now joins them: for the label that isn’t the background (the commonest label, or one not drawn), else for the pair the corner pixel is nearer in color, and always the corner pixel nearer the pair’s color, the anti-aliased half of the step. Every preset but Poster then makes 8 of 8 there (Logo 176 nodes instead of 1126), and the other fixtures score the same. On photos it cut error 2% for 5% more size, so Poster doesn’t join. Gap closing proper (pairing the ends of lines that really are broken, as Fourey et al. 2018 do) waits for a fixture where it is needed.

Stacked flat art is layers, each shape whole. Cut out, a shape partly behind another is only its visible pixels: on the overlap fixture a moon behind a bar came out as an odd sliver, and only 3 of its 8 shapes were whole. The layered-vectorization papers (LIVE 2022 onward) find layers by optimizing on a GPU; flat art shows the old cue instead, good continuation at T-junctions. Where the boundary between two shapes ends, the shape whose outline carries straight on (under 20°) is in front if the other turns sharply there (over 40°), and votes over both ends of every shared boundary decide, with no vote against. Paint order is back to front, otherwise largest first. Each hidden run of a back shape’s outline is then replaced by the circle its visible outline lies on (within 0.5 px RMS, over at least a quarter turn), the corner where its straight sides meet, or a curve along its tangents, whichever comes first and stays under the shapes in front. Both the new edge and the whole area it adds must be under shapes painted later: the badge’s lower ring once took a straight edge across the hill that also covered a navy sliver, and lost it. All 8 overlap shapes now come out whole, the badge scores the same, and with holes that later shapes fill dropped (the paper is one rectangle) Illustration uses about half the nodes on the junction fixtures. Photos keep their own stacking, which reaches under every later neighbor so no seam shows; flat art keeps cut-out seams, as before. Illustration and Outline art stack by default; Logo stays cut out, for vinyl.

Edges sit between pixels when the image is clean. Chains run along pixel cracks, so every edge was on the pixel grid, up to half a pixel off, and a small shape came out lumpy. Open Vectorizer (MIT) reads an anti-aliased pixel as a measurement instead: between colors A and B it is a blend, a share α of A. With A’s pixel and B’s either side of a crack, and each solidly its color one and two pixels further in, the edge is α_A + α_B − 1 px off the crack (at most 0.35 px). Each crack’s midpoint moves by that, a crack too near a corner to be measured takes the nearest measured offset along its own run, and a pixel corner between two runs of three or more moves by both, so a bar’s square ends stay square. On a synthetic rectangle with sides inside pixels, the fitted sides land within 0.05 px, with exact corners, where the grid rounded them. Only for images saved without loss: on JPEG the blends beside an edge are skewed by ringing, and the overlap fixture got worse (0.18% to 0.19% wrong), so it applies only when 99% of the pixels inside regions are within 3 levels of their color (PNGs of the fixtures: 99.99%; JPEG q72: 84–97%). That is judged from the pixels before merged inks or lines relabel any, so a lossless WebP or a very clean JPEG counts too, and a small image the app enlarges (with a blur) passes but finds no solid pixels beside its edges, so traces the same. Poster never uses it. On the PNG badge, emblem, outline and overlap fixtures wrong pixels fall 2–16% for the same nodes; brightness alone gives the blend where the colors differ in it.

Exact shapes are chosen by drawing them, near the limit (#147). The strict limits on how far a shape may stray from its pixel edges (RMS 0.3 px, worst 0.85 px) stay, and a shape inside them is used as before. A shape inside looser limits (0.5 px, 1.4 px) is now drawn as well as the free fit, and each is scored by the area where it and the region’s outline differ (areaApart in shapes.ts: scanlines a quarter of a pixel apart, even-odd); the shape is kept if it is off by no more than 0.9 of the free fit’s. And a region taken for a circle is also drawn as each regular polygon of 3 to 8 sides, of its area and centroid, turned to the angle that fits it best; a polygon replaces the circle only when it is off by less than 0.6 of the circle’s area. That catches the small hexagon: 5 to 8 px across, its corners are too blunt in pixels to find, its moments are a circle’s, and it came out round. Anti-aliased, it now comes out a hexagon from 5 px; drawn with hard pixel edges it stays round under about 10 px, where the pixels can’t tell the two apart. Circles of every size tried stay circles. The score: the outline fixture 2.02% to 2.00% wrong (Logo; Illustration and Outline art the same 0.01–0.02 better), the PNG overlap fixture 0.19% to 0.16% with Illustration, nodes unchanged everywhere; Line art on the 3.2 px junctions 3.11% to 3.13%. Open Vectorizer as a second benchmark in score is not done.

Nearly straight lines snap to 0°, 45° and 90°. People draw those with a snap, but a fit to the pixels leaves them a fraction of a degree off, more after JPEG: on the outline and junction fixtures about a third of the long lines were under 1° from square (a 191 px edge 1.15 px out of level). A line at least 8 px long and within 1° of horizontal, vertical or 45° is made exactly that (snapLines in fit.ts), turned about its middle or about an open chain’s end, which stays fixed so the edge is still shared exactly; neighboring lines in one direction become one line, and each node moves to where its snapped lines meet (at most 1.5 px, else the line is left), turning the handle of a curve beside it too, so a smooth join stays smooth. A needle whose two sides snap level, opposite ways, is left as fitted, since no point is on both. Lines either side of a junction that both snap pass through it, so they come out collinear too. Exact shapes are not snapped (a regular polygon would stop being regular), nor is the editor’s Simplify, which refits what someone drew. The badge’s 43° and 47° sides are 1.7° and 2.3° from 45° and stay as drawn, which is what set 1°. Wrong pixels are unchanged within ±0.02 points (score, score:photos) and nodes the same or a few fewer (outline fixture with Logo, 330 to 328); files grow about 2%, since a snapped line through the mean of its nodes rarely lands on a whole pixel. Near-parallel lines that are not square are left alone for now.

PolyFit’s polygon-first corners would not help. PolyFit (Dominici et al. 2020, MIT) fits a polygon to the pixels first, then a random forest picks a curve or a corner for each run; people preferred it to earlier tracers on low-resolution clip art. Its research code builds on Linux after small fixes (Windows dirent.h and cairo.lib, MSVC-only syntax). It takes exact colors, so the fixtures were rendered at 32, 64 and 128 px with every pixel snapped to its palette color, traced by both, and compared with the clean art at 640 px (skipping a one-pixel border). In black and white, PolyFit’s home ground, it got up to 7 times as many pixels wrong as Logo, never fewer (emblem at 64 px: 3.9% against 1.4%; badge at 128: 6.2% against 0.9%), used more nodes in all but two cases, took 0.2 s to 7 min against Inlay’s 20 to 100 ms, and crashed on an internal check for 2 of the 18 inputs (on 6 of 12 in color, where it also leaves pixel steps at three-color junctions). Part of the gap is that its outlines run through the boundary pixels’ centers, about 0.7 px inside a shape. By eye, its corners are not better either: it rounds the emblem’s top point that Inlay keeps sharp and turns the round hole into a diamond. The one thing it does better is keep some of the pinwheel’s leaf tips sharp at 64 px, where Inlay rounds them, since a corner’s sides are measured 3 to 9 px out and a leaf at 64 px is barely wider than that. At 128 px both keep most tips. So nothing from PolyFit is ported, and it stays out of score, as it needs a patched C++ build.

Soft shading becomes gradients again (#150). A palette splits a smooth shade into bands of flat tints: on a test drawing with two linear gradients and a radial one (shaded.svg), Illustration drew 20 shapes and got 32.5% of pixels wrong, since a band’s one color is off by more than the score allows across most of its width. With gradients, two regions are one shade when their boundary is soft: across it, over three pixels, the image changes by under 0.4 of the difference between their colors (a hard edge, even anti-aliased, changes by all of it), or by under 10 levels, as JPEG blocks alone make bands of close tints in a photo palette look hard. Each shade is then fitted in closed form, in sRGB as SVG draws it: each channel as a plane for a linear gradient (the planes’ main direction is its axis), and the color’s main component as a + bx + cy + d(x² + y²) for a radial one, whose vertex is the center, refined by Gauss–Newton; then up to five evenly spaced stops along the axis or the radius, as few as come within a level of the best. It is kept when it at least halves a flat color’s error and is no more than 10% worse than the bands; a neighboring region the gradient draws at least as well as its own color then joins (a band whose edge was too short to judge, or a lighter speck on the shade’s anti-aliased rim). On the test drawing Illustration then draws 6 shapes with 0.19% wrong and 61 nodes (from 397), and Poster 7 shapes for 1,540 nodes down to 93; every other fixture traces the same with it on. On the three photos Poster’s error is unchanged (10.41 to 10.43), with 3% fewer shapes and 70% more time, so Poster leaves it off; so do Logo and anything cut out, since a cutter can only cut flat color. In the package it is an option, off by default.

A faint background is one shape. AI-made logos often sit on a near-white background with a vignette too slight to see, about 25 levels from corner to corner. Pale tints (a light fill on white is that close too) split it into three or four ragged bands, which on a dump-truck logo made a third of the SVG. Logo, Illustration and Outline art now join neighboring regions whose colors are within 0.07 of each other in OKLab (closer than the peak walk tells apart) when the image passes between them without an edge: across at least half of their boundary it steps by under 0.4 of their colors’ difference, both over three pixels and between the two pixels themselves (so a line one pixel wide still counts as an edge), with no allowance for noise. A pale fill on white steps by its whole difference, so it stays. The joined run, if its shades span no more than 0.1, takes its commonest color, and its edges are fitted without sub-pixel placement, which would read the blend against that color rather than the band’s. It stays flat in Illustration too: a gradient over the truck’s vignette, which isn’t one straight ramp, drew some band over 10 levels off, and letting faint shades skip the per-band check would also smear a close pastel shape into a soft background. With your own palette it is off, as every color there was chosen. On the truck, Logo went from 107 to 63 KB and Illustration from 126 to 71 KB, the background one shape and the truck unchanged pixel for pixel.

Blurry flat art is solved for, not sharpened. A soft photo of a printed logo traced with a pale band around every shape: each edge is a ramp, and the ramp’s middle is nearest some third palette color. Everything that works on the ramp itself failed on the test image, a dump-truck logo (Nov 2026). Unsharp masking and Richardson–Lucy sharpened the grain and kept the band; a color shock filter made hard edges but turned the band solid; growing regions from the flat areas lost the thin trim; giving each edge pixel the nearer of the colors either side lost the halo and left ragged shapes; Real-ESRGAN and Restormer (defocus deblurring; tested only, its license is academic) barely sharpened it. deblur (Remove blur) fits a model instead: the map of a few flat colors that, blurred as the image was, best matches it, at the least boundary. The blur is measured per edge (contrast ÷ steepest slope ÷ √2π) and pooled into a map by block medians, since a photo taken at an angle is sharper on one side (the truck: 3.5 px across the middle, 7–8 at the left); the colors are the commonest of the flat areas, plus any no blend of two of those explains (a pinstripe’s). The search starts from each pixel’s nearest color and flips pixels one at a time, down the picture and back up, wherever misfit plus boundary drops, then re-reads thin areas of a color two others blend to as those two: a line thinner than the blur fades to the blend’s color and is first read as a wider line of it, which no single flip gets out of. Only a line running through one color is re-read so. A strip between two different colors can as well be the wider, duller strip it was first read as, and under a blur nothing tells the two apart: the truck’s cab-gray strip between the orange trim and the navy rim came back as a pale hairline until this was the rule. The map that comes out is right about where the shapes are and wrong about their edges in the small: its pixels step along every slant, and a photo of print has a texture of its own that the search fits faithfully, rippling each edge by a pixel or so every few pixels. Charging more for boundary did not help (the ripple is in the photo, so straightening it costs misfit, and a cost high enough to pay for that takes the thin detail first). Under a blur the photo cannot place an edge to better than a share of the blur anyway, so the edges are cleaned up as geometry: every boundary between two areas is walked, cut at its corners, and smoothed along its length by as much as moves no point further than 0.6 of the blur there (less beside a thin area). A straight edge comes out straight. Two things had to be right. Smoothing a curve pulls it inwards, so what a pass takes off is smoothed and put back, and an amount of smoothing is used only where that pull is under half a pixel; without this every round shape shrank by up to the tolerance (the fixtures’ wrong pixels went up three- to five-fold). And a corner is where its two sides, run on as straight lines, meet: the search rounds it off, and ending each side at the rounded point bends the whole side towards it. Smoothing still leaves a slow wobble in, a pixel or two over a hundred, and under a heavy blur the lumps the search drew. So a stretch that one line fits to within what each of its points may move, and that bows off the line by under a quarter of a pixel, is drawn as that line, and two such lines meet where they cross: over half the truck’s boundary length. The lines are better placed than the corner found before them (drawing them through that corner instead doubled the icons fixture’s wrong pixels), and two runs that meet at under 0.3 rad, or bow the way they turn, are a curve drawn as chords and stay smoothed (a wheel arch came out a polygon without that). Placing each edge from the photo’s own ramp afterwards was tried and dropped: on a blurred circle the smoothed edge was already within 0.12 px of true (rms), and the refit made that 0.10 with a pull inwards on curves. The picture is then drawn along those boundaries at twice its size and halved, for anti-aliased edges. Slivers no more than two pixels wide, left where three colors’ ramps cross and read as gaps between shapes, are given to their neighbors first where the photo barely notices; only between two colors, since with one color all round such an area is a thin line (a 3 px line on a 2048 px picture, solved at a quarter of its size, is one work pixel wide, and was erased until this was the rule). What mattered most was what the blur acted on. A lens blurs light; a resize or a filter blurs the stored sRGB values, and the same step blurred each way differs by about half a blur in where its middle sits. Modeled as light, the truck (blurred as stored, it turned out) came back with every dark outline too fat. Now the starkest edges’ ramps decide: blurred as light they are lopsided (by 1.5–5% of their width; as stored, under 1%). To measure any of this the sharp artwork was registered onto the photo and edges compared: of the output’s edges, the share within 2 px of a true one, and of the true edges, the share found. Tracing the photo as it is: 53% and 64%. The light model: 61% and 50%. Now: 79% and 68%, and the Logo trace went from 411 KB with halos to 71 KB without, the orange trim back. On the score fixtures blurred by 2 and 3.5 px, wrong pixels fell from 1.5–8% to 0.03–1% on flat art (emblem, icons, pinwheel, overlap, badge; the badge blurred as light by 3.5 px, 9.5 → 3.5%). It is opt in, suggested when an image measures soft (over 1.6 px), because it only suits flat color: shading comes out flat (the shaded fixture got worse, 0.8 → 2.2%), art with no flat areas is returned as it was (strokes), hairlines that never reach their own color are not recovered (outline at 3.5 px: 2.6 → 3.8%), and where the blur is wider than the details (the truck’s left tire, at 7–8 px) they come back rounded or merged. A picture over 420,000 pixels is solved at a half, a third or a quarter of its size, for time; a line under about two of those work pixels wide is kept, but in the color it fades to and a little wide. About 4 s for a megapixel image, and traceAsync pauses after each sweep of the search.

Only the latest request ever waits. Dragging a slider fires many trace requests a second and a trace can take a second or more. TraceClient holds at most one waiting request per channel (trace, optimize), replacing it when a newer one arrives, so the preview is never more than one trace behind the slider. The worker is created lazily because React StrictMode’s double effect run would otherwise leave the app holding a terminated worker in development.

The numbers shown are the numbers exported. Path, node and byte counts come from the SVGO-optimized output, computed in the background after each change, not from the raw trace. Before this, the panel showed 41 KB for a file that downloaded at 31 KB.

One domain, two halves. The app started as a tool at mattblack.space/tools/img-to-svg/, proxied by the portfolio, so it was built to live at that same path on both hosts. With inlaytrace.com it moved to /app/, beside the landing page at / and the docs at /docs/, all one Vercel project. The old path redirects permanently, with an absolute URL so the portfolio’s proxy passes the redirect through rather than following it. The site builds to dist/ first, because Astro empties its output folder, and the app builds into dist/app after it.

One copy of each doc. docs/*.md is the source: Boards reads it, and scripts/sync-docs.mjs copies it into Starlight at build time (title from the first heading, order to sidebar order, .md links to site URLs). Planning notes such as the launch plan are left out.

The landing page’s evidence is measured. npm run site:assets traces the app’s sample as the app receives it (640 px JPEG) with Inlay and with VTracer as the old Logo preset ran it, scores both against the clean art at 4×, and writes the shapes and numbers the page draws. The close-up is pinned to the left peak: the window where VTracer is most wrong by pixel count is a gentle curve where the two look the same, and the page’s claim is about corners and straight edges. On this sample VTracer’s shared edges stay within 0.06 px of each other, so the page does not claim it leaves gaps.

The CSP is tested, not trusted. There are three, and Vercel applies every matching header block, so they’re scoped never to overlap. The app’s needs a worker allowance (without it the page loads, accepts a drop, and never traces) and must not allow 'wasm-unsafe-eval'; the AI worker’s file (/app/assets/prep-*.js) gets the same policy plus 'wasm-unsafe-eval', since a dedicated worker runs under the policy its own script is served with. The site’s is script-src 'self' plus 'wasm-unsafe-eval' for search (Pagefind) and the sha256 of each inline script Starlight writes (theme, sidebar). npm run hosting:check fails the build if any of that goes missing; after the build, --dist hashes every inline script in the site and fails on one the CSP doesn’t list (so a Starlight update fails the build, not the docs) or on any inline script in the app. npm run preview (scripts/serve.mjs) serves dist/ with vercel.json’s redirects, rewrites and headers, and verify fails on any CSP violation in the console.

Untrusted output stays out of the markup. The trace is shown inline (the overlays and hit targets need real DOM paths), so every d, fill and transform is validated against what the tracers emit before it is rebuilt into the document. Recolors are normalized hex or ignored.

Edits sit on top of the trace until they can’t. The document is { inks, doc, background }. Color edits (inks) are keyed by the traced color, so they survive re-tracing, as does the background. doc stays null, meaning “whatever the tracer produces”, until the first geometric edit (a node drag, a delete, a mirror) copies the trace into an editable document with fresh ids. From then on a trace setting would throw the edits away, so changing one asks first; going back to the trace is itself an undoable step. Undo/redo stores whole snapshots (cheap at these sizes, capped at 100) and coalesces a drag or a color-picker sweep into one step.

Path data is normalized once, then round-trips exactly. Editing converts each path to absolute M/L/C/Z nodes with explicit handles (apps/app/src/lib/pathdata.ts). Numbers are written to three decimals and the serialiser is idempotent, so touching one node never nudges the rest of the drawing.

Mirror is two booleans per shape. For each path: intersect it with the kept half-plane, reflect that across the axis, and unite the two. A shape that crossed the axis comes out as one seamless shape rather than two halves that meet; shapes entirely on the discarded side are dropped; paint order and fills are kept. The geometry is paper.js (MIT), loaded only when you mirror: 72 KB gzipped against an 89 KB app. The unit tests run the same core build under jsdom, and verify renders the exported SVG and compares each half against the other (0.0% of pixels differ on a real logo).

Moves and scales are measured from the start of the drag. Each pointer move sends the whole transform since the press, and it is applied to the shapes as they were then. Applying increments instead would compound rounding over a long drag. The starting shapes are captured in the event handler, not inside the state updater: React can run the updater after the handler has already cleared them at the end of the drag, and in an early version that applied the final move twice (a 30 px drag moved 60 px). The browser check drags by a known distance and measures the result.

Smooth nodes stay smooth. A node whose two handles are in line (within 10°) is smooth, which is how the tracer writes curves that meet with matching tangents. Dragging one of its handles swings the other round to stay opposite, keeping its length; ⌥ breaks the pair. Whether a node is smooth is decided at the press, so a drag that bends a handle past the threshold doesn’t suddenly let go of its partner.

Marquees take shapes wholly inside. Touching is the other common rule, but a trace usually has one large shape behind everything, and touching would add it to every selection. A marquee can start in the margin around the image, for when that background shape covers all of it.

PDF and EPS are written by hand. Both are a few path operators per shape (moveto, lineto, curveto, closepath, fill), so a library would add more than it saves. The PDF is five objects with a Flate-compressed content stream and a byte-exact cross-reference table; the tests check every offset, and the file passes qpdf --check and renders back the same as the SVG in Poppler. Coordinates are flipped (both formats put the origin bottom-left) and scaled from the viewBox to points.

A gradient is a fill, not an ink. The trace writes a shaded shape’s fill as url(#…) #rrggbb: the gradient, then its average color as the fallback. The app keys the shape’s ink by that color, so the palette, ink edits and per-color layers work as before, and replacing the color fills the shape flat (a recolored gradient would need a rule for every stop, and flat is what someone replacing a color usually wants). The gradient is read into numbers and colors and written back from them, never copied as markup. Moving, scaling or turning a shape composes the transform into the gradient’s own gradientTransform, so the gradient goes with it exactly, even under a stretch; a node edit leaves it where it is. Mirror can’t join a shaded shape to its copy, as one path has one gradient, so it keeps the two halves (or the turned copies) as shapes of their own, each copy’s gradient mirrored or turned with it. A shaded ink can’t be merged: its color is an average no pixel is labeled with. PDF clips a shading (sh, axial or radial, its color a stitching of linear pieces, extended past both ends as SVG pads) to the path; EPS does the same with PostScript 3’s shfill; DXF has no fills. Stacked Illustration and Outline art turn it on; Logo, Poster and anything cut out don’t.

Merging colors happens before regions exist. Making two colors the same leaves two shapes and the seam between them. Merging relabels one color’s pixels as the other’s after palette labeling (so anti-aliased edges were still judged against both) and before specks, components and edges are built, so the seam never exists. It’s a trace setting, so it costs a re-trace and asks first after shape edits.

Overlays never export. The canvas is three layers: the original, the vector exactly as exported, and an overlay svg with hit targets, outlines, nodes, handles and the mirror axis. Nodes and handles are sized in screen pixels (scaled by the current zoom), so they stay grabbable at 8×. A press only becomes a drag after 3 px of travel and keeps the grab offset, so clicking a node selects it without nudging it. Invisible hit targets sit beneath every visible node, so a neighbor’s target can’t steal the node under the pointer.

Zoom is a scale, not a level. Zoom is stored as screen pixels per original pixel (null means fit, which follows the window), so 100% means the same thing however large the image was traced. The slider and the ± steps are logarithmic (√2 a step), and steps stop at fit and at 100% rather than skipping past them. A trackpad pinch over the canvas zooms around the cursor: Chrome, Firefox and Edge send it as ctrl+wheel, Safari as gesture events, and both are handled; ⌘/Ctrl + wheel, ⌘/Ctrl + = − 0 1 work too. Past fit, the sheet gets half a window of padding on each side, which is what lets the point under the cursor stay put (0.1% drift over a 1,100% pinch) even near an edge.

Busy traces stay responsive. A Poster trace of a photo can be 2,500 paths and 60,000 nodes. The node overlay is one <path> and is skipped (with a note) past 20,000 nodes; each shape is a memoized element; path data is validated once per path, not per render; and the stats panel measures only the optimized file. On that trace a node drag went from 117 ms to 25 ms a move, and toggling the overlay from 2.4 s to 0.3 s.

Poster moved to Inlay last, and a bug was the gap. Photos stayed on VTracer because they have no histogram peaks and cut-out shapes cost size on them. Inlay gained a quantized palette (k-means in OKLab, seeded deterministically) and a stacked mode, but the first photo scores were poor: ten times VTracer’s shapes and 2.5 times its size. A larger speck setting made it worse, which pointed at the cause: merging specks ran once, so a speck that joined a small region which then joined a third was stranded as a new speck. Clean art never cascades; photos did thousands of times. Repeating the merge until nothing is left took the photos from 5,150 shapes to 222, and Inlay then beat VTracer on all three photos (mean error 14.3 → 11.8, 57% fewer shapes, 30% smaller), so the app dropped VTracer, its WebAssembly and the 'wasm-unsafe-eval' allowance. Stacking itself saves less than expected on photos (about 3%): most photo regions are small and have few holes. A radius-2 blur before tracing cut error a further 10%, but softens real edges; it’s left for a future setting. At 2048 px Poster takes 3.4–5.1 s on these photos in Node, about 15% longer than VTracer took (2.9–4.5 s), and the SVG is about 30% larger at that size; at the photos’ own size (450–640 px wide) it’s both smaller and closer.

Stacked shapes still had seams, between neighbors. Stacking covers a hole with what fills it, but two shapes side by side over a third each anti-alias their shared edge, and the third shows through as a darker hairline; more colors meant more such edges, so raising Poster’s colors seemed to add random lines. Drawing each shape in its own color as a 0.5 px outline cut error on a product photo by 11%, which measured the seams’ cost. The fix keeps plain fills: each shape’s outline is now that of itself plus every neighbor painted after it (still from the same fitted edges), so every edge is drawn once, by the later shape over the earlier one’s color. A hole in that outline stays open if a shape painted earlier is inside it, or transparency. On the three photos mean error went 11.83 → 10.42 (12%) for 37% more path data (148.7 → 203.1 KB, still under VTracer’s 212.6).

Poster’s outlines came out jagged. A painted drawing (flat shading, 9 px black outlines, saved as JPEG at 2048 px) traced well with Poster, shading included, except that every outline had notches and bumps along it. Poster’s 24 clusters spent five on the outline, near-blacks 0.02–0.03 from one to the next (brush grain and JPEG noise spread the ink that far), so the outline labeled as several hundred pieces, blotched into each other. Two things followed, and each got its fix.

Pieces of the ink became paper. Many pieces were under the 64 px speck size. A speck joined the color it shared the most edge with, and a piece at the outline’s edge touches more paper than any one of the other near-blacks: 9% of the outline’s pixels became paper or the fill beside it, a bite each time. It is the stroke bug flat art had (above), and the fix is a part of that one: a speck in a photo still joins the color it shares the most edge with, but only among the colors around it within 0.1 (OKLab) of the nearest to its own; and a speck whose neighbor took its color earlier in the pass stays, when nothing else that near is beside it. On the three photos mean error went 10.41 → 9.37 for 12% more shapes and 4% more bytes.

The ink stayed in pieces. Each piece’s stretch of the outline’s edge was fitted on its own, with a kink where two pieces met, and the line showed its patchwork up close. Merging close clusters in the palette is not the answer: by distance alone (single link under 0.035) the five near-blacks join, but so does the pot’s lit terracotta with its shaded one, through a tint between them 0.033 from the first and 0.019 from the second. What tells them apart is where they are, not what they are: the near-blacks are blotched into each other (0.9–1.3 edges between two of them per pixel of the rarer), and the lit and shaded terracotta, 0.05 apart, meet along one edge (0.01). Flat art already settles such pairs region by region (settleClosePairs: a region of two close colors that is blotched with both takes the one nearer its mean), and Poster now does too, between clusters under 0.035 apart in regions with over 0.2 edges per pixel of the rarer. The distance is what photos allow: a wooden table’s grain is two tints 0.035–0.04 apart, as blotched as the ink, and at 0.04 it went flat; at flat art’s 0.07 and 0.1 photos were 17% further from the photo. It runs over each color’s own pixels now, not the whole image for each pair, so a photo’s dozens of close pairs cost little.

On the drawing the outline is now two near-blacks 0.016 apart in 32 shapes (with 8 small pieces of the other three), where it was 388; the whole trace is 117 shapes and 132 KB, from 533 and 367 KB; and the lit and shaded bands are as they were. What it flattens is the grain inside a band, where two tints under 0.035 apart were blotched together. On the three photos, both fixes together: mean error 10.41 → 9.21 (12%), the same 222 shapes, 5% fewer bytes (203.9 → 194.0 KB). On the fixtures Poster keeps regions it dropped (the badge 9 → 12 of 12, the outline illustration 12 → 19 of 20) in fewer nodes on the badge (1280 → 731); the outline illustration’s lines come out as 10 pieces for 7 drawn, where they were 5.

The line was still two or three inks. Settled a pair at a time, each stretch of the outline went to whichever of its two near-blacks was nearer, so lengths of different near-blacks lay end to end: 1,080 px of seam between them on the drawing, in 46 pieces. Each seam showed three ways. The line’s edge was fitted in two stretches with a kink where the seam met it; the two inks claim the soft rim differently, so the line stepped in width there; and some pieces were 0.046 from the ink beside them, enough to see. Every jagged spot left on the drawing was one of these (Illustration, which gives the outline one color, has none). The answer is to settle the whole chain at once: the blotched regions of every close pair are joined where they overlap, and the joined region takes the color, of those it holds, nearest its mean (settleLines, before settleClosePairs). A chain can drift a long way, though, which is why pairs alone were safe: joined like this a cat’s fur ran through 17 clusters 0.27 apart end to end and went flat (mean error 9.77 → 15.73), and the pot’s lit and shaded terracotta joined through the tint between them. So a joined region settles only when it is a line of one ink: at least half of it in thin, long parts (no wider than 16 px at 2048 px, and wider in step with a larger image; the outline’s regions were 66–100%, the fills 0–10%, the fur 33%), the colors it holds no more than 0.1 apart (the five near-blacks were 0.078 end to end; a thin bar shading from #1e1e1e to #3c3c3c is 0.12, a ramp, and settled as a line it went one flat gray), and at most a fifth of its pixels further than 0.05 from its mean color (the ink’s were 3–5%, its soft rim; the fur’s 30–54%). Everything else is left to the pairs, as before. A line that runs into a large solid area of the same ink (black hair, a filled shadow more than about its own area) fails the thin share with it, and keeps its seams.

On the drawing each connected outline is now one ink: 4 px of seam left, 9 dark shapes for 46, the whole trace 84 shapes and 81 KB (from 117 and 130 KB), with every band of shading where it was. Outlines that don’t touch can still take different near-blacks (two here, 0.016 apart). The three photos are where they were (mean error 9.21 → 9.20, the same 222 shapes, 194.0 → 192.0 KB; the rocket’s gantries, thin dark trusses, are a little plainer), and so are the fixtures. It costs time: about 15% more on the 2048 px drawing (2.0 → 2.3 s) and on the photos.

The outline illustration’s 10 pieces for 7 are not this. Its lines are 3.2 px wide at 640 px, so after JPEG no pixel of them is the ink: the clusters along a line run from #51748d to #a4c5dc, a real ramp 0.2 long, not one shade in blotches, and every stretch is under the speck size. Where a stretch comes out in one of the lighter blues the score reads it as fill, and the line counts as broken. (The 5 before these fixes was no better: pieces were missing, with 12 of 20 regions found. It was 7 after the speck rule, 8 after the pairs, 10 after the review’s changes to the speck rule.) Outline art is the preset for such lines.

Known limit: the edge count can’t tell a blotch from a thin clean band. A stripe under about 10 px wide in a tint under 0.035 from its surround (4 px stripes of #b16243 on #c06845) passes for blotched and is flattened too; a blotch’s own pieces are bands 2–4 px wide along the line. Wider bands, and any 0.035 or more apart, are kept. Your own palette is never settled (the presets pass faint: false), and a speck beside transparency goes to it by edge unless a shade of its own ink is beside it.

A test for two peaks was measured and doesn’t separate them on JPEGs. Along the line from one cluster to the other, clean stripes are two peaks with nothing between and a blotch is one spread: the pixels in the middle third against those on the rarer side were 0 for the stripes drawn clean or saved at quality 80 and up, but 0.11–0.5 at quality 72 and under (2–8 px stripes), while the blotched regions of the drawing and the three photos ran from 0.19 up. Only a lossless or lightly compressed stripe could be told apart, so the limit stands.

Also tried: fitting an edge straight through a junction whose third boundary is between two near-identical colors, so pieces of one outline don’t each get their own stretch of its edge. It cost 7% more bytes and 5% more error on the photos (it rounds real corners at junctions), and settling the pieces into one region does the same job without it. And for the chain: joining touching pixels of any close pair in one pass, without asking each pair’s region to be blotched, was twice as fast on photos but muddied a 4 px sliver between two fills (the overlap fixture, 0.66% → 0.84% wrong), since the soft rim between two colors is a chain of close clusters too.

Centerline is a skeleton, not an outline (#38). Plotters and engravers want one stroke per line. AutoTrace does this but is GPL, so Inlay grew its own: the ink is thinned (Zhang–Suen), then any pixel whose neighbors stay connected without it is dropped, because Zhang–Suen leaves the line two pixels thick at staircases, and every one of those read as a junction: a ring came out as four strokes until that pass, and as one after. The width started as twice the median distance transform along the skeleton, but that is out by a pixel on even widths (the skeleton can’t sit on the middle), so it is the ink’s area over the skeleton’s length instead: 9.58 px for strokes drawn 9.6 px wide. Strokes that carry straight through a crossing are joined, so a plus sign is two pen strokes, not four.

AI steps run in a worker with its own policy (#39). Background removal (U²-Net small, Apache 2.0, 4.4 MB) and 4× upscaling (Real-ESRGAN general v3, BSD 3-Clause, converted from its PyTorch release to ONNX unchanged, 4.9 MB) run with ONNX Runtime Web’s WebAssembly backend (MIT, 3.7 MB compressed), one thread so no cross-origin isolation is needed. Rather than allow WebAssembly for the whole app again, only the worker’s script is served with 'wasm-unsafe-eval'; Chromium compiles under the worker’s policy, and the page stays without it. On a 600 px photo background removal took about 3 s the first time (download included); upscaling a 120 × 80 mark about 2 s. The steps give a prepared copy of the image that is traced and compared against instead of the original; the original is still what’s saved.

Gap closing joins only small breaks, measured in widths and pixels (#145). A broken outline lets a fill leak and costs a plotter a pen lift, but some gaps are drawn. On a new fixture (broken.svg, 3.2 px lines broken 1.6–3.8 px apart, plus dashes four widths apart), Line art and Centerline went from 13 pieces to all 9 and Outline art to 10 (its T is two straight strokes it keeps as shapes, outside the lines it joins), with wrong pixels unchanged. A limit in widths alone (1.6) joined the 8 px junction fixture’s dashes, a width apart, and the pen drawing’s chimney, 10 px short of its roof: so it’s capped at 5.5 px too. A JPEG’s or a faint pen’s breaks are a few pixels on any line. Every other fixture scored as before. Ends come from the pruned skeleton (its degree-1 pixels) rather than GIMP’s curvature on the ink’s border, since the skeleton is already there for Centerline and Outline art, and its direction is taken a few widths back, past the end’s round cap.

A grainy poster lost its small shading and a face. A screen-printed poster (767 × 1024, saved lossily; a girl running over stylized fish) traced in Illustration without the darker band in her hair or the inside of her mouth, and at 2× her face came out pale gray. Its grain unflattens fills: only half its pixels pass the flat test (four neighbors within 8 a channel), under the 80% that close fills need, so peakPalette’s walk alone decides. Both misses were in it. The hair’s brown (0.06% of the image) and the mouth’s dark red (0.08%) are under minShare and lie on the line from their fill to the navy outline, so they were dropped as anti-aliased edges. At 2× the blend of the white rain and the light-blue water (0.6%, 5.1% flat, just past the 5% that marks an edge) came before the skin in the walk, and then shut it out, 0.06 away.

What tells a fill from an edge here is a test that grain doesn’t break: a pixel is solid when its four neighbors are within 0.04 of it in OKLab. An edge between two colors steps a tenth or more, so its blends measured 0 to 0.03 solid; the hair’s band (1–3 px wide) 0.31 and the mouth 0.69. A color whose weight is at least 15% solid is no longer an edge, at any share, and a blend under half solid is picked after the rest of the walk, so a fill near it comes first. On the poster the hair’s shading and the mouth come back at 1×, and at 2× the face as well, with its eyebrows and nose. score was unchanged but for the painted figure, where Illustration keeps 7 of its 14 regions, from 5 (2.16% → 2.12% wrong). Illustration and Logo on the three photos: one more color on the rocket (3% bigger), the others the same. The solid pass costs about 10% of a trace’s time.

In an image enlarged for tracing, the four neighbors are that many pixels away: one pixel of the image at its own size. A small image is enlarged with a blur, which gives a faint 1 px line a smooth, flat crest, solid by the pixel beside it: a dark-red ring left on a 160 × 320 black-and-white image could trace as a third color. What the browser check for Clean up’s threshold did catch was plainer: a smudge of #0b0000 left on black, flat and solid, which OKLab puts 0.07 from black though nobody can see it. So a solid color must also be 24 levels (all channels together) from every color picked. The app passes how far it enlarged the image whenever it traces Logo, Illustration or Outline art, so the test is the same one with or without the other options that use scale.

A blurred image passes the test by its neighbors too: across a soft edge every step is small, so each band of the slope looked solid, and a disc blurred 6 px picked up eight colors where it had four. A pixel is not solid when the color keeps changing the same way over five samples in a row (two each side, along whichever of x and y changes more). Grain steps both ways: five samples run one way 1 time in 60. A blend that waits for the end of the walk keeps its place under the color limit, so a full palette can’t push out a fill it would have had.

At 2× the fish’s big eye on the right then traced as a black disc. Its dark rim was painted after the white inside it (the rim was voted in front), with a thin shaded ring between the two painted after both. A stacked flat shape keeps a hole only if a shape painted before it is across the hole’s edge, and only the shaded ring was, so the rim was drawn whole over the white. A hole now stays if a shape painted earlier is anywhere inside it (found by walking the regions that touch, from its edge inwards, without crossing the shape itself). score was unchanged.

The poster’s line work was the last of it. Its face is drawn in 1 px near-black lines, which the palette never sees as a color (0.03% of the image, all anti-aliasing), so they traced in navy or the hair’s brown. Keep painted outlines is the step that darkens thin lines until they label as ink, but on this poster it made things worse: the print’s stipple is dark specks too, close enough together to pass as lines that run a while, so 12% of the image was marked, the skin came out freckled, the hair’s shading lost its solid inside (and its place in the palette), and the SVG doubled (1.3 → 2.5 MB at 2×). Grain differs from a line in being light specks as well as dark: so a line must now also be 1.25 times deeper than the light specks within the radius are high (the image minus its opening, at half the radius: at the whole radius the paint between two lines drawn close together counted as a speck, and hatching lost its lines). On the poster 2.7% is marked, the brows, eye rims, nose and the outline of the face and hair trace near-black with the shading intact, and the SVG is 1.45 MB. At 2 times, the painted trouser-leg test lost its faint outline (10 levels deep in ±3 of brush texture), which set the factor. On the score’s painted figure, Illustration with outlines went 2.47% → 2.19% wrong in 209 nodes (from 358), with the same 5 of 14 regions as before; it does not gain the two regions the palette change gave the other rows.

Tried and dropped for the same lines, without the option: reading thin, never-solid pixels of a blend color as the mix they are (brows turned orange and white where another pair fitted better; with one ink only, the darkest color, it helped only once a near-black was in the palette, and enlarged 2× there is none: its 1–2 px outlines are 0.025% of the image, a dark tail on the navy); picking an enlarged image’s palette from a shrunk copy (the blur stays); and a palette pass for colors no blend reaches (the tail is under minDetail).