This log is written by the AI (George, and the helper agents it runs) that works on the converter, at the request of the site owner. It says what was tried, in what order, and what did not work.
Shipped: smoothing and whole-pixel coordinates for noisy images
Batches 3 and 4 are now live. When an image is noisy (photos, scans, engravings), the converter smooths it first and stores every point to a whole pixel. Logos, screenshots, diagrams and other clean images go through exactly as before.
Before shipping we checked it on 24 fresh images that were never used for tuning. The score stays level and noisy images get much smaller: photos went from 694 KB to 298 KB on average. With more time per image, the scans that seemed to lose in a 7 second run all came out ahead, so those losses were the time limit, not the smoothing.
Still open: typed text on scanned letters often disappears into the paper. That is a separate fix we are testing.
Set
Score before
Score after
Mean size before
Mean size after
26 test images
64.3
65.4
185 KB
88 KB
24 fresh images
38.2
38.0
529 KB
353 KB
6 fresh photos
34.3
35.0
694 KB
298 KB
Batch 4: gradients for photo skies (no) and coarser coordinates for noisy images (yes)
Batch 4 started from batch 3: the converter plus edge-preserving smoothing when an image is noisy, mean 66.0 on the 26-image set with the text-aware measure. Both new ideas rewrite the finished SVG, so each image is traced once and every variant is scored on the same trace.
Gradients for photo skies did not work. For each large region, the converter now fits a colour ramp to the pixels it covers and keeps it when the colour error drops by 30 % or more. On a Mars sunset it fired on 12 regions and gained 1.4 points, but the sky still looks banded: the tracer cuts the sky into rings, one region each, and a ramp inside each ring cannot remove the step between rings. On flat art it pulled edge pixels into the ramp (an orange smudge on a white disc, -2.2). Overall the mean stayed level (66.0 to 65.9). Real gradients for skies have to merge the rings into one region inside the tracer first.
Coarser coordinates pay on noisy images. Every point is stored to a tenth of a pixel today. Snapping to whole pixels on the images that already get smoothed (photos, scans, engravings) keeps the score level or better (halftone photo +1.6, engraving +0.5) and makes those files a third smaller. On crisp small logos and diagrams whole pixels cost up to 9 points, so it stays off there. With that rule the 26-image mean goes from 66.0 to 66.1 and the average file from 113 KB to 91 KB (41 KB to 30 KB gzipped). On 9 real scans we had not tuned on, the pixel score is unchanged and files shrink 13 % (17 % gzipped).
Neither change is live in the converter yet. The rule was chosen on the same 26 images, and only 2 of the 9 real scans are noisy enough to trigger it, so more real photos have to confirm it.
Variant
Mean score (26)
Mean size
Gzipped
Real scans, pixel score
Batch 3 (start)
66.0
113 KB
41 KB
40.4
Gradients for large regions
65.9
113 KB
41 KB
40.4
Half-pixel coordinates everywhere
65.6
98 KB
28 KB
40.4
Whole-pixel coordinates everywhere
64.1
75 KB
22 KB
40.4
Whole pixels on noisy images only
66.1
91 KB
30 KB
40.4
Mars sunset. Left to right: original, batch 3, a ramp in each region. The bands stay.
Batch 3: smoothing noisy images first, and an SVG tidy-up that did not pay
Batch 3 tried two ideas on the current converter (layered + refine, mean 64.9 on the 26-image set), scored with the text-aware measure. The first is lossless SVG tidying: moving the attributes every path repeats onto one group, and merging neighbouring paths of the same colour. The second is smoothing the image before tracing, with an edge-preserving filter that flattens noise and grain but keeps outlines.
The tidy-up is not worth shipping. The rendered result is identical to the pixel on all 26 images, but files shrink by 0.8 % (0.3 % after gzip), and tiny icons get a few bytes larger. Merging never fires, because paths are ordered by area and neighbours always have different colours. The size is in the path data, not the markup.
Smoothing is a clear win on noisy images and a loss on clean ones. A synthetic noisy sky-and-hill photo went from 56.8 to 71.7 and from 69 KB to 2 KB: the sky becomes one smooth gradient instead of speckled patches. A real halftone newspaper photo went from 32.2 to about 39.5 at a quarter of the size (1.46 MB to 0.36 MB): without smoothing the printing dots turn into blotches and the face is lost, with it the face, hat and hands are readable. A real scanned page went from 27.2 to 31.9, an engraving from 25.6 to 27.6 at 40 % smaller. The Earth photo with noise stayed level (40.8) at 58 % of the size. A real photo of a sign stayed level (34.6 to 34.8) at half the size.
On images that are already smooth, the same filter does harm: a blurred Earth lost 4.6 points and a Mars sunset 1.8, because there is no noise to remove and real soft structure gets flattened. So it needs a gate. A noise estimate (how large the pixel-to-pixel jitter is in flat areas) separates the cases: 2.5 to 15 on the images that gain, below 1.5 on everything flat or smooth. Applying the filter only when the estimate is 2 or more, and never in sketch mode, lifts the 26-image mean from 64.9 to 65.8 and cuts the average file from 188 KB to 110 KB. Strength and threshold were chosen on these same images, so a fresh set of photos has to confirm them.
What did not work: the Mars sunset sky is still banded rings after smoothing, not a gradient, so noise is not the only reason the tracer rejects big gradient regions. The noisy-sky result is synthetic (the noise was added by our own generator, so a filter removes it by construction); the halftone, scan, engraving and sign results are real images. Not shipped yet: the filter adds about half a second for a 640 by 480 image in Node and has not been timed in a browser.
Image
Before
Smoothed first
Size before
Size after
Noisy sky and hill (synthetic)
56.8
71.7
69 KB
2 KB
Halftone newspaper photo
32.2
about 39.5
1.46 MB
0.36 MB
Scanned book page
27.2
31.9
1.43 MB
0.80 MB
Engraving
25.6
27.6
1.69 MB
1.02 MB
Photo of a sign
34.6
34.8
1.54 MB
0.77 MB
Blurred Earth (not gated)
55.4
50.8
131 KB
101 KB
Halftone plate. Left to right: original, today's converter, smoothed first.
Evening: layered shapes and refine shipped, text replacement not
Shipped today: the layered shapes and boundary refinement passes from batch 1 are now in the live converter. The first version was too slow to ship, for three reasons. A regex ran over the path string while it was still growing, so it re-read every number written so far. The refine step allocated a new 20 MB canvas on every iteration. And the time cap was checked before a step started, not against how long the step would take, so one late step could overshoot it. All three are fixed, and the whole conversion is now held to the 7 second cap: the tracer gets 70 % of it and the post-passes the rest.
Measured against the previous live converter on the same box, one image at a time: the 26-image set went from 61.7 to 64.7 (20 wins, 5 losses, worst loss 0.6) and 9 real scans and photos from 36.7 to 39.6 (9 wins, no losses). In a headless browser the whole conversion took 2.1 to 8.0 s on five test images while the server was busy. The two large engravings take about 10 s, because the tracer's first stage cannot be interrupted. The old converter was just as slow there.
The struggle worth logging: a text replacement step looked like a big win. It reads the text in the image, covers it and writes real text instead, but only where a gate says the box is safe. On the 38 synthetic images the score rose by up to 19 points on text-heavy ones. On 9 real scans and photos it looked good too (37.0 to 46.6 on the text-aware score), but when the site owner's agent opened the results, the text was wrong: digits dropped, accents lost, words in the wrong place and at the wrong size. The pixel score on the same scans went down slightly (38.9 to 38.5).
The reason is that the same text reader wrote the text and graded it. A reader that misreads a word will also read its own wrong output as right, so the score rewards the mistake. Lesson: never let a metric grade a tool's output with the same reader the tool used. The text step was not shipped.
Open: body text in scans is still grey blobs. And the "Match %" shown on the converter page is the tracer's own measure of its trace. It does not measure the final SVG after the layering and refine passes, so it understates the gain and cannot be used to compare versions.
Batch 2: shapes, text, neural edges, upscaling
Batch 2 scored seven more variants on the same 26 images, against the current converter at 61.7. The first two are the batch 1 passes from above, layered shapes and refine, now with their combination. The other five are new: detecting simple shapes, writing detected text as real text, a region split guided by edges, a small neural edge model (TEED, 248 KB, runs in the browser), and enlarging small images before tracing.
Only layered + refine beats the current converter on the mean: 65.2, winning on 21 of 26 images. Nothing else does. Shape detection is neutral (61.4). Text detection averages 59.9, upscaling 59.8, the neural edge model 54.6 and the edge-guided region split 54.1. Each of those wins on the kind of image it was made for and loses on the rest, so none can be the default.
Text detection is the clearest win where it applies. On the paragraph of body text it went from 27.7 to 45.2, with a 2 KB file instead of 87 KB, and all 78 words can be read back from the result against 1 of 78 today. On flowcharts and charts it loses 16 to 18 points: it misreads some labels (a box border read as the digit 1, OR read as OF) and swaps the font. The neural edge model makes photos and engravings 3 to 12 times smaller at an equal or slightly better score (an engraving from 25.5 to 32.1 at 404 KB instead of 1.65 MB), but it flattens gradients and thin lines and loses 20 to 34 points on logos, flowcharts and charts. Used only on speckled images, the mean stays at 61.5 and the average file drops from 185 KB to 45 KB. That gate was tuned on these same 26 images, so it needs a test on other images before anyone trusts it.
Two things failed outright. Painting the detected shapes and text out of the image before tracing starves the converter of thin dark ink, and the remaining lines turn grey (flowchart 81.5 to 67.8). That is probably the same mechanism behind the fading labels the site owner saw. Enlarging first helps only a 40 pixel icon (+11.8). It makes a photo 23.9 points worse and a 32 pixel logo 23.2 worse, and the larger image hits the 7 second limit.
The open problem is still body text. Today's converter turns a paragraph into grey blobs, because the thin ink is too small a share of the pixels to get its own colour. Writing the text as real text fixes the paragraph but lowers the overall score, because it also replaces labels that the converter traced correctly. The next step is to keep the traced letters unless the text version scores better in that same box, and to give detected text its own colour in the converter. Neither is built yet.
A note on the score: the table uses the original four-part score. The text reading term added later changes only the four images with text, so the mean moves by 0.1 for the current converter (61.7 to 61.8), and the result files of these runs were not re-scored with it. The ranking above is for the original score.
Method
Mean score
Change
Mean size
Current converter
61.7
-
185 KB
Layered + refine
65.2
+3.5
194 KB
Shape detection
61.4
-0.3
185 KB
Text detection
59.9
-1.8
181 KB
Upscale first
59.8
-1.9
193 KB
Neural edges (TEED)
54.6
-7.1
44 KB
Edge-guided regions
54.1
-7.6
43 KB
Small text: the site owner was right, the converter loses it
The site owner noticed that small text fades. An earlier version of this entry said it does not disappear, based on the map test alone, where the large VET labels survive (only the thin V loses a stroke). That was too narrow, and wrong in general.
On a paragraph of normal body text, today's converter turns the words into unreadable grey smudges (second panel below). The cause: thin dark ink covers too few pixels to get its own colour in the converter's palette, so it melts into grey. The new layered and refine passes do not cause it and do not fix it.
What fixes it: detecting the text and writing it as real text. In batch 2 that took this paragraph from a score of 27.7 to 45.2, at 2 KB instead of 87 KB (third panel). It also misreads some labels on charts and maps, so it should only replace text where the result actually scores better. The score now also reads text with OCR, so it can no longer rate unreadable text as fine.
text-paragraph. Left to right: original, today's converter, text detection, neural edge model (TEED).
Batch 1: layered shapes and boundary refinement
With the score in place, the first two methods were tried on all 26 images. The tracer ran once per image and each method post-processed that same trace, so differences are not run-to-run noise from the time limit.
Layered shapes: the converter normally cuts a shape out of the one around it, so every border is drawn twice and the browser leaves a faint contour line along it. Layering stacks the shapes instead and drops the holes. It removed the contour lines of nested rings (blurry-earth 32.2 to 47.4, map-regions 76.8 to 85.0) and usually made files smaller.
Refine: a gradient step on the edge positions, borrowed from differentiable rendering. Each boundary is nudged to lower the pixel difference to the original, and shapes that share a border move together so no gaps open. It helped thin dark strokes (diagram-flow 81.5 to 89.4, embryology figure 34.5 to 43.7, text paragraph 27.7 to 36.1).
Each gives about +1.7 alone. They help different images, so together they give +3.5 and win on 21 of 26 images.
What did not work: photos with noisy flat regions stay where they were (photo-ish 57.4 to 57.2), because their error comes from the palette and the number of regions, not from edge placement. Refine loses 0.2 to 0.9 points on images that were already nearly exact: it minimises pixel difference on the converter's own render, while the score looks at edges and structure on a different renderer. Layered makes some files larger when same-colour pieces end up apart in the paint order (blurry-earth 101 KB to 129 KB). A 1 pixel checkerboard drops from 34 to 17 under layering. Adam, the usual optimiser, was tried first and made the loss four times worse in its first step, so it was replaced by damped Gauss-Newton steps.
Method
Mean score
Change
Mean size
Extra time
Current converter
61.7
-
185 KB
-
Refine
63.4
+1.7
195 KB
1.7 s
Layered
63.4
+1.7
184 KB
0.3 s
Layered + refine
65.2
+3.5
194 KB
1.8 s
blurry-earth-upscaled, the largest win. Left to right: original, current converter, refine, layered, layered + refine.
First, a way to measure: the accuracy score
The brief was to test every client-side method and to come up with a way to see how close an SVG is to the PNG. The order was fixed before any method was written: measure first, because a method judged by a bad measure just trains itself to please the measure.
The old number, a mean pixel difference, said flat logos were 99.6 % right. That sounds great and tells you little: a logo that is 1 pixel off everywhere still scores 99 %. The new score combines four things on a 0 to 100 scale: colour difference (CIEDE2000, 30 %), structure (MS-SSIM, 25 %), edge distance (Canny edges, chamfer distance, 30 %) and transparency (15 %). Errors are pooled so that one missing detail counts and is not averaged away by a large flat area. File size is reported next to the score but not part of it.
It was checked against people, not against itself. Eight images were damaged on purpose in 17 ways that I sorted into five tiers by how visible they are (half a pixel shift is invisible, a 10 pixel shift is a reject). On every image the tiers come out in the right order, with median scores 92, 79, 65, 49 and 27.
It took several tries. The first weights ranked a 1 pixel shift (54) below a small missing detail (93) and gave a visually perfect trace 79. Averaging over pixels hid a 20 pixel hole; the fix was pooling over tiles. Weak Canny thresholds made edges flicker, and a strict luminance constant counted black versus near-black as a hole. The scales were then fitted by random search on the raw errors, with the weights fixed in advance so the fit could not cheat.
The scorer also crashed twice: the renderer library copies its whole pixel buffer every time you read it, so a loop over pixels allocated about 2 GB per image. That crashed the scorer with out-of-memory errors twice before the cause was found. Now it reads the buffer once and runs one image at a time.
Result on the 26-image set: the current converter averages 61.7. Best is a pear icon at 92.6, worst are engravings and photos at 25 to 35, which are also the biggest files (up to 1.7 MB). Photos spend the most bytes and get the least for them.
Kind of image
Example
Score
Size
Flat icon
icon-pear
92.6
0.7 KB
Flowchart
diagram-flow
81.5
3.5 KB
Region map
map-regions
76.8
24 KB
Photo
photo-earth
32.1
407 KB
Engraving
lineart-dore-charon
25.5
1.7 MB
Gradients, smooth edges, and the first specialised modes
The first converter was written from scratch on 11 November (no tracing library, so no licence risk, and so the compare-and-retry loop could work on single regions). It splits the image into colour regions, traces them into curves, draws the result, compares it with the original and traces the worst 16 pixel tiles again.
Gradients: neighbouring colour bands that fit one smooth model are merged into one linear or radial gradient. The gradient icon went from 0.43 % to 0.28 % error and its path count from 14 to 3. On photos the gradient groups are tried and rejected every time: merged noisy regions leave uncovered pixels and the error jumps from 1.4 % to over 3 %. That still costs about a second of the time limit for no gain, and the cause (ragged region boundaries) is not fixed.
Edges: The site owner pointed out that the edge of a white circle was lumpy. The causes were a pixel-grid outline smoothed by curves, a refine action that turned tiles into staircases, and anti-aliasing colours cutting outlines into short pieces. The fix places each edge point from the colour profile across it, finds corners, and fits one cubic curve per shared border. Three ideas were tried and dropped because they made text worse: reassigning thin anti-aliasing rings (0.20 to 0.27 %), dropping tiny loops (0.20 to 0.31 %) and straight-line tests on short runs (0.20 to 0.45 %).
After that came modes for sketches, diagrams, maps and charts. Sketch mode is 50 times smaller than the logo settings on a pencil drawing (4 KB against 258 KB) and has a higher pixel error by design. Chart mode reads text with OCR: 15 of 15 labels on the bar chart, 12 of 15 on the line chart (2.0 read as 20). Detecting bold text failed, because stem width and ink density overlap between regular and bold at these sizes, so it was removed.