Repository navigation
Expand file tree
/
Copy path01-intake.html
More file actions
493 lines (483 loc) · 35.4 KB
/
Copy path01-intake.html
File metadata and controls
493 lines (483 loc) · 35.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Intake — inkvec</title>
<link rel="stylesheet" href="assets/doc.css">
</head>
<body>
<div class="wrap">
<header class="masthead">
<p class="eyebrow">Stage 1 of 16</p>
<h1>Giving the file a fair reading before anything else runs</h1>
<p class="standfirst">Before a single shape is traced, the file has to be checked for
things that would otherwise be mistaken for artwork: a sneaky resize, a compressed
file pretending to be clean, transparency that has nowhere to go in the maths, and a
size the rest of the tool was never calibrated against. This stage settles all of
that, quietly, so every later stage can trust the pixels it is handed.</p>
<p class="pairlink">Technical reference: <a href="01-intake.md">01-intake.md</a></p>
</header>
<main>
<section>
<h2>The file is not the same thing as the drawing</h2>
<p>It is tempting to think of a PNG or a JPEG as simply "the picture" — open it, trace
what is there. But a raster file is one snapshot of a drawing, at one size, saved by
one program, and any of those three facts can quietly work against the tracer.</p>
<p>Someone with a small logo who wants a large one often resizes the file first, with
the crudest possible method, before it ever reaches this tool. A photo-style
compressed file adds faint ripples of colour near edges that were never part of the
original artwork. And a file with a transparent background hands the tracer a
problem it has no way to solve directly — the maths behind reading an edge (stage 2)
needs two solid colours to measure a boundary against, not one colour and a
see-through hole.</p>
<p>Intake is where all of that gets sorted out, before the palette, the boundaries, or
anything downstream ever looks at a pixel.</p>
</section>
<section>
<h2>Reading the file the way a viewer shows it</h2>
<p>The first job is simply to read the file, and to read it the way an image viewer
would, because the picture a person drops on the tool is the picture they saw.</p>
<ul>
<li><b>The file's own bytes decide what kind of file it is, not its name.</b> Every
image format starts with a short signature, and the tool reads that. A JPEG saved
with a <code>.png</code> name, or a PNG renamed to <code>.jpg</code> — common after a
browser's "save image as" — used to be refused; it is now read as what it is, pixel
for pixel the same as the correctly named file. Only when the bytes carry no
signature at all does the name choose how to read them.</li>
<li><b>A phone photo is turned upright.</b> Cameras store the picture as the sensor
saw it and add a small note saying which way up to show it. Every viewer follows the
note; the tracer used to ignore it and traced such photos on their side. It now turns
the picture the way the note says before anything is traced, and reports the size
the right way round too.</li>
<li><b>A colour profile is converted to ordinary screen colours.</b> Some files carry
a profile saying their numbers belong to a different colour space — a Mac screenshot
in Display P3, a photo in Adobe RGB, an old print file with a different brightness
curve. A viewer converts those to the colours the screen shows, and now the tracer
does the same, converting to sRGB. On six test images with such a profile the colour
error fell from 0.85 to 0.12 on average, measured before and after the change on
the same run. A profile that already describes sRGB
leaves the file exactly as it was.</li>
<li><b>An empty image is refused.</b> A damaged file can decode to a picture that is
zero pixels wide or zero pixels tall. There is nothing to trace in it, and it used to
crash a later step; it is now turned away at once with a plain error saying it has no
pixels.</li>
<li><b>A very large file that will be shrunk anyway is allowed more room while it is
read.</b> A file over the size limit is reduced as it is read, so the tool lets such
a decode use up to 1.25 GiB rather than refusing a large but genuine picture. A
file that only pretends to be enormous, a few kilobytes claiming billions of pixels,
is still refused before any memory is spent on it.</li>
</ul>
</section>
<section>
<h2>Undoing an accidental zoom</h2>
<p>Resize a small image with the simplest method a computer offers — "nearest
neighbour" — and every pixel becomes a solid square block, four, eight, sixteen
times its original size. Nothing new was drawn; the same handful of pixels was just
repeated. A tracer that does not know this happened will faithfully draw the
staircase of block edges, because as far as it can tell, that staircase <em>is</em>
the artwork.</p>
<figure>
<svg viewBox="0 0 640 260" role="img" aria-label="A small pixelated logo blown up by nearest-neighbour resizing into large blocky squares, then undone back to the original small grid">
<text x="20" y="24" class="fig-label-strong">A block upscale, and its exact inverse</text>
<g transform="translate(20,50)">
<text x="0" y="-8" class="fig-label">original, 4x4</text>
<g transform="translate(0,0)">
<rect x="0" y="0" width="80" height="80" fill="none" class="fig-rule"/>
<rect x="0" y="0" width="20" height="20" class="fig-ink"/>
<rect x="20" y="0" width="20" height="20" class="fig-ink"/>
<rect x="40" y="0" width="20" height="20" fill="var(--paper)"/>
<rect x="60" y="0" width="20" height="20" fill="var(--paper)"/>
<rect x="0" y="20" width="20" height="20" class="fig-ink"/>
<rect x="20" y="20" width="20" height="20" class="fig-accent"/>
<rect x="40" y="20" width="20" height="20" class="fig-accent"/>
<rect x="60" y="20" width="20" height="20" fill="var(--paper)"/>
<rect x="0" y="40" width="20" height="20" fill="var(--paper)"/>
<rect x="20" y="40" width="20" height="20" class="fig-accent"/>
<rect x="40" y="40" width="20" height="20" class="fig-accent"/>
<rect x="60" y="40" width="20" height="20" class="fig-ink"/>
<rect x="0" y="60" width="20" height="20" fill="var(--paper)"/>
<rect x="20" y="60" width="20" height="20" fill="var(--paper)"/>
<rect x="40" y="60" width="20" height="20" class="fig-ink"/>
<rect x="60" y="60" width="20" height="20" class="fig-ink"/>
<g class="fig-rule" stroke-width="1">
<line x1="20" y1="0" x2="20" y2="80"/><line x1="40" y1="0" x2="40" y2="80"/><line x1="60" y1="0" x2="60" y2="80"/>
<line x1="0" y1="20" x2="80" y2="20"/><line x1="0" y1="40" x2="80" y2="40"/><line x1="0" y1="60" x2="80" y2="60"/>
</g>
</g>
</g>
<text x="150" y="90" text-anchor="middle" class="fig-label-strong" fill="var(--copper)">viewer resizes 4x -></text>
<g transform="translate(240,50)">
<text x="0" y="-8" class="fig-label">what arrives, 16x16 of blocky squares</text>
<g transform="translate(0,0)">
<rect x="0" y="0" width="80" height="80" fill="none" class="fig-rule"/>
<rect x="0" y="0" width="20" height="20" class="fig-ink"/>
<rect x="20" y="0" width="20" height="20" class="fig-ink"/>
<rect x="40" y="0" width="20" height="20" fill="var(--paper)"/>
<rect x="60" y="0" width="20" height="20" fill="var(--paper)"/>
<rect x="0" y="20" width="20" height="20" class="fig-ink"/>
<rect x="20" y="20" width="20" height="20" class="fig-accent"/>
<rect x="40" y="20" width="20" height="20" class="fig-accent"/>
<rect x="60" y="20" width="20" height="20" fill="var(--paper)"/>
<rect x="0" y="40" width="20" height="20" fill="var(--paper)"/>
<rect x="20" y="40" width="20" height="20" class="fig-accent"/>
<rect x="40" y="40" width="20" height="20" class="fig-accent"/>
<rect x="60" y="40" width="20" height="20" class="fig-ink"/>
<rect x="0" y="60" width="20" height="20" fill="var(--paper)"/>
<rect x="20" y="60" width="20" height="20" fill="var(--paper)"/>
<rect x="40" y="60" width="20" height="20" class="fig-ink"/>
<rect x="60" y="60" width="20" height="20" class="fig-ink"/>
<g class="fig-rule" stroke-width="0.5" opacity="0.6">
<line x1="5" y1="0" x2="5" y2="80"/><line x1="10" y1="0" x2="10" y2="80"/><line x1="15" y1="0" x2="15" y2="80"/>
<line x1="25" y1="0" x2="25" y2="80"/><line x1="30" y1="0" x2="30" y2="80"/><line x1="35" y1="0" x2="35" y2="80"/>
<line x1="45" y1="0" x2="45" y2="80"/><line x1="50" y1="0" x2="50" y2="80"/><line x1="55" y1="0" x2="55" y2="80"/>
<line x1="65" y1="0" x2="65" y2="80"/><line x1="70" y1="0" x2="70" y2="80"/><line x1="75" y1="0" x2="75" y2="80"/>
<line x1="0" y1="5" x2="80" y2="5"/><line x1="0" y1="10" x2="80" y2="10"/><line x1="0" y1="15" x2="80" y2="15"/>
<line x1="0" y1="25" x2="80" y2="25"/><line x1="0" y1="30" x2="80" y2="30"/><line x1="0" y1="35" x2="80" y2="35"/>
<line x1="0" y1="45" x2="80" y2="45"/><line x1="0" y1="50" x2="80" y2="50"/><line x1="0" y1="55" x2="80" y2="55"/>
<line x1="0" y1="65" x2="80" y2="65"/><line x1="0" y1="70" x2="80" y2="70"/><line x1="0" y1="75" x2="80" y2="75"/>
</g>
</g>
<text x="40" y="100" text-anchor="middle" class="fig-label">every 4x4 block is one flat colour, exactly</text>
</g>
<text x="460" y="90" text-anchor="middle" class="fig-label-strong" fill="var(--copper)">detected -> averaged back down</text>
<g transform="translate(540,50)">
<text x="0" y="-8" class="fig-label">traced at</text>
<rect x="0" y="0" width="80" height="80" fill="none" class="fig-rule"/>
<rect x="0" y="0" width="20" height="20" class="fig-ink"/>
<rect x="20" y="0" width="20" height="20" class="fig-ink"/>
<rect x="40" y="0" width="20" height="20" fill="var(--paper)"/>
<rect x="60" y="0" width="20" height="20" fill="var(--paper)"/>
<rect x="0" y="20" width="20" height="20" class="fig-ink"/>
<rect x="20" y="20" width="20" height="20" class="fig-accent"/>
<rect x="40" y="20" width="20" height="20" class="fig-accent"/>
<rect x="60" y="20" width="20" height="20" fill="var(--paper)"/>
<rect x="0" y="40" width="20" height="20" fill="var(--paper)"/>
<rect x="20" y="40" width="20" height="20" class="fig-accent"/>
<rect x="40" y="40" width="20" height="20" class="fig-accent"/>
<rect x="60" y="40" width="20" height="20" class="fig-ink"/>
<rect x="0" y="60" width="20" height="20" fill="var(--paper)"/>
<rect x="20" y="60" width="20" height="20" fill="var(--paper)"/>
<rect x="40" y="60" width="20" height="20" class="fig-ink"/>
<rect x="60" y="60" width="20" height="20" class="fig-ink"/>
<g class="fig-rule" stroke-width="1">
<line x1="20" y1="0" x2="20" y2="80"/><line x1="40" y1="0" x2="40" y2="80"/><line x1="60" y1="0" x2="60" y2="80"/>
<line x1="0" y1="20" x2="80" y2="20"/><line x1="0" y1="40" x2="80" y2="40"/><line x1="0" y1="60" x2="80" y2="60"/>
</g>
<text x="40" y="100" text-anchor="middle" class="fig-label">identical to the original</text>
</g>
</svg>
<figcaption>The blow-up is exactly reversible: keep one pixel from every constant block
and the original pixels come back unchanged. Once that pattern is recognised, the
tracer works on the small original — and still writes the SVG at the size the file
claimed.</figcaption>
</figure>
<p>This check is deliberately strict — every pixel in every block has to match
exactly, with no wiggle room. A looser test would also catch a logo that genuinely
contains large flat squares, and undoing those would throw away real artwork. On a
96-pixel logo blown up to 768 pixels, skipping this step means the tracer describes
the staircase directly: thirteen colours instead of three, and over fifteen hundred
straight little lines walking around pixel corners instead of the handful of smooth
curves the artist actually drew.</p>
<p>The zoom need not be a whole number. A browser at 350 % turns each pixel into a
block three or four pixels wide, alternating, and until October 2026 the tool only
recognised whole-number blow-ups, so such a picture was traced block by block: on 28
test images, thirteen times the artist's number of points and a colour error three
times what the original pixels give. The check now looks at where the colour changes
from one column (and one row) of pixels to the next. In a blow-up, every change sits
at the start of a block, and the block starts follow the zoom factor to within one
pixel; the tool finds the one factor, whole or not, whose block starts include every
change, keeps one pixel per block, and checks that repeating those pixels rebuilds
the picture exactly before it trusts the answer. On ordinary artwork two neighbouring
columns both change somewhere within the first few rows of the drawing, which no
blow-up of two or more can do, and the check ends there. All 28 of the 3.5× images
came back as their originals, and on all the benchmark's ordinary images the check
never fired.</p>
<p>It also stopped giving up early on wide, short logos. A wordmark 128 pixels wide and
50 tall, blown up four times, used to be undone only halfway, because the original
rule refused to leave fewer than 64 pixels on either side; now only the long side
keeps that floor.</p>
</section>
<section>
<h2>Images that were enlarged smoothly</h2>
<p>Most image editors enlarge with a smooth filter instead, and then there are no
blocks to find: every edge of the drawing is simply spread over several pixels.
That is just as misleading to a tracer built for crisp one-pixel edges — the
in-between colours of each smeared edge look like extra inks, and the extra pixels
look like extra detail to describe. When every strong edge in the picture is wider
than a crisp drawing can make one, and the spread says it was enlarged three times or
more, the tool shrinks the picture back by that factor first (keeping the thinnest
strokes at least three pixels wide), traces the smaller version, and writes the SVG at
the original size. On images enlarged four times this way, the colour error fell by
about 30 % and the number of points by two thirds.</p>
<p>Two kinds of picture look soft but are left alone. A crisp logo with a soft glow or
drop shadow has smeared edges too — the glow's — but its own edges are still sharp,
and the tool checks for that before it shrinks anything; an earlier version did not,
and blurred such logos down to a fraction of their size. And an image enlarged only
twice is traced as it is, because shrinking it measured slightly worse than leaving
it.</p>
</section>
<section>
<h2>Telling a compressed file from a clean one</h2>
<p>Photo-style compression (the kind JPEG uses) does not blur an edge — it leaves the
edge itself mostly alone and instead adds a faint ripple of colour in the flat areas
just beside it, an artefact of how the compressor represents smooth regions cheaply.
Two different checks were tried to catch this automatically, and both were fooled,
for related reasons worth stating honestly rather than glossing over:</p>
<ul>
<li>Measuring how <em>wide</em> an edge is does not see it, because the ripple does
not widen the edge — it sits beside it, in territory the width measurement is not
looking at.</li>
<li>Measuring random noise in flat areas does not see it either, because the ripple
only occupies a thin band next to each edge; an icon is mostly empty, so the
"typical" noise level across the whole image stays at its floor, exactly as it
would on a perfectly clean file.</li>
</ul>
<p>This was not a hypothetical risk. A real compressed logo measured a native
1.15-pixel edge width against a 1.75-pixel threshold meant to catch resizing damage —
comfortably under it — so the safeguard that should have caught the damage stayed
off, and the tracer dutifully treated the compression ripple as real ink. The result
was <b>243 separate paths across 1301 separate regions, 89% of which together
covered only 5% of the drawing</b> — noise, not artwork, each ripple minted as its
own tiny shape.</p>
<figure>
<svg viewBox="0 0 640 200" role="img" aria-label="A clean edge compared with a compressed edge that rings with faint colour ripples beside it; both read the same width and the same noise level, and only reading the file format tells them apart">
<text x="20" y="22" class="fig-label-strong">Same edge width, same noise reading, different history</text>
<g transform="translate(20,50)">
<text x="0" y="0" class="fig-label">clean file</text>
<rect x="0" y="10" width="150" height="40" fill="var(--paper)" stroke="var(--rule)"/>
<rect x="150" y="10" width="6" height="40" fill="#8a837b"/>
<rect x="156" y="10" width="150" height="40" class="fig-ink"/>
<text x="153" y="70" text-anchor="middle" class="fig-label">edge width 1.15px, noise at the floor</text>
</g>
<g transform="translate(20,120)">
<text x="0" y="0" class="fig-label">compressed file</text>
<rect x="0" y="10" width="150" height="40" fill="var(--paper)" stroke="var(--rule)"/>
<path d="M 40,10 v40 M 60,10 v40 M 80,10 v40 M 100,10 v40 M 120,10 v40 M 140,10 v40"
stroke="var(--copper-soft)" stroke-width="10" opacity="0.55"/>
<rect x="150" y="10" width="6" height="40" fill="#8a837b"/>
<rect x="156" y="10" width="150" height="40" class="fig-ink"/>
<path d="M 160,10 v40 M 175,10 v40 M 195,10 v40 M 220,10 v40 M 250,10 v40 M 285,10 v40"
stroke="var(--copper-soft)" stroke-width="10" opacity="0.4"/>
<text x="153" y="70" text-anchor="middle" class="fig-label">edge still reads 1.15px; the ripples never widen it</text>
</g>
<g transform="translate(360,55)">
<text x="0" y="0" class="fig-label-strong" fill="var(--copper)">The honest fix: ask the file</text>
<text x="0" y="26" class="fig-label">JPEG and one flavour of WebP</text>
<text x="0" y="44" class="fig-label">are always lossy. PNG, GIF,</text>
<text x="0" y="62" class="fig-label">BMP and TIFF never are. The</text>
<text x="0" y="80" class="fig-label">container format says so</text>
<text x="0" y="98" class="fig-label">directly — no inference needed.</text>
<text x="0" y="130" class="fig-label-strong">243 paths, 1301 faces</text>
<text x="0" y="148" class="fig-label" fill="var(--copper)">-> 80 paths, 654 faces</text>
<text x="0" y="166" class="fig-label">artwork intact, ripples gone</text>
</g>
</svg>
<figcaption>Neither pixel-level check can separate lossy ringing from a clean file —
one reads the same width either way, the other reads the same noise floor either
way. The fix asks a question the pixels cannot answer: what format was this file
actually saved in.</figcaption>
</figure>
<p>A third pixel-level idea was also tried and also refuted: measuring how jagged the
colour is in supposedly flat areas. It separated clean files from compressed ones
cleanly — until it met a genuinely clean smooth gradient, which scored as more
"damaged" than the compressed flat icon, because ordinary 8-bit colour ramps produce
the same kind of small jumps a lossy codec does. None of those three checks could
separate the two. So the fix did not try to get cleverer about pixels — it reads the
file's own container format, which states the fact exactly rather than estimating it.
A JPEG is lossy. A PNG is not. A WebP says which of its two internal codecs it used,
right there in its header.</p>
<p>The container has one blind spot: a JPEG re-saved as a PNG no longer admits what
was done to it. A later, more targeted pixel check covers that case. Instead of asking
how much ripple there is, it asks where the ripple sits — in a band a few pixels out
from each edge, where clean artwork is perfectly flat — and whether it flips up and
down from one pixel to the next, as compression ripple does and a smooth gradient
does not. It now switches on the same safeguard; the palette stage describes it in
full.</p>
<p>This matters for a reason beyond one file type. Turning this safeguard on
unconditionally, for every file whether it needs it or not, was tried and measured:
it costs 10.9% on the tool's own quality benchmark, because on a genuinely clean
file, two very similar colours really are two different inks the artist chose, and
merging them throws real artwork away. The safeguard has to stay off until there is
real evidence — a wide edge, a compressed file format, or that ripple pattern — that
it is needed.</p>
</section>
<section>
<h2>Same logo, four times the pixels, wildly different results</h2>
<p>Export the same logo as a 128-pixel PNG and as a 512-pixel PNG. It is the same
drawing. It should cost the same number of points and curves to describe in an SVG.
For a long time, it did not — and the reason is worth walking through carefully,
because it is one of the more surprising things about how this tool was tuned.</p>
<p>Every measurement this tool takes is stated in pixels: how confidently an edge is
located, how precisely a coordinate is written down, how big a stray speck has to be
before it is worth ignoring. All of those numbers were chosen by testing against
images around 128 pixels on a side. Hand the same logo in at 512 pixels and nothing
about those numbers changes automatically — but the boundary itself is now drawn
with four times as many points, each one sitting four times as far (in raw pixels)
from where a simplified curve would put it, for exactly the same shape. The
book-keeping that is supposed to discourage adding unnecessary detail barely
reacted — it only grew by a small, slow amount, nowhere near enough to offset how
much more "wrong" a simplified curve now looks in raw-pixel terms. Faced with that
imbalance, the tool kept buying more and more detail it did not actually need, one
cheap-looking segment at a time.</p>
<p>Measured directly, on real brand logos, the effect was severe and got worse with
size: <b>3.54 times the artist's own number of points at 128 pixels, 6.02 times at
256, 11.62 times at 512</b> — for a mark whose actual complexity had not changed at
all.</p>
<figure>
<svg viewBox="0 0 640 230" role="img" aria-label="The same star shape traced at two different resolutions; without correction the larger raster is described with far more unnecessary points, with correction it comes back with the same handful" >
<text x="20" y="22" class="fig-label-strong">Same shape, priced per pixel versus priced per unit of content</text>
<g transform="translate(40,50)">
<text x="30" y="-10" text-anchor="middle" class="fig-label">128px export</text>
<polygon points="30,0 38,22 62,22 42,36 50,58 30,44 10,58 18,36 -2,22 22,22"
fill="none" stroke="var(--ink)" stroke-width="2"/>
<text x="30" y="80" text-anchor="middle" class="fig-label">a handful of points</text>
</g>
<g transform="translate(230,20)">
<text x="60" y="-10" text-anchor="middle" class="fig-label">512px export, priced per raw pixel</text>
<polygon points="60,0 68,10 78,14 70,24 100,44 88,48 92,68 76,66 62,86 58,72 40,86 42,64 20,66 30,48 4,42 26,26 20,10 44,16"
fill="none" stroke="var(--copper)" stroke-width="2"/>
<text x="60" y="105" text-anchor="middle" class="fig-label" fill="var(--copper)">11.62x the points, same star</text>
</g>
<g transform="translate(460,50)">
<text x="30" y="-10" text-anchor="middle" class="fig-label">512px, priced per unit of content</text>
<polygon points="30,0 38,22 62,22 42,36 50,58 30,44 10,58 18,36 -2,22 22,22"
fill="none" class="fig-accent-stroke" stroke-width="2"/>
<text x="30" y="80" text-anchor="middle" class="fig-label" fill="var(--copper)">back to a handful</text>
</g>
<text x="320" y="200" text-anchor="middle" class="fig-label">The fix: measure how many pixels the raster spends on each unit of detail, and price
every curve against the drawing's own scale rather than raw pixels.</text>
</svg>
<figcaption>Nothing about the artwork changed between the middle and right panels —
only how "close enough" and "worth another point" were priced.</figcaption>
</figure>
<p>The fix is to stop pricing everything in raw pixels and start pricing it per unit of
the drawing's own content. The question is not how big the raster is — a crisp
1024-pixel drawing can be full of genuine detail — but how many pixels it spends on
each unit of detail. The tool measures that two ways: how wide an edge is (a resize,
a blur or a photograph smears it over several pixels), and how far the picture can be
shrunk and blown back up without losing anything (a simple drawing exported larger
than it needs survives that round trip untouched, even with razor-sharp edges).</p>
<p>One correction is always on in the full-quality mode. When the round trip says the
raster carries the drawing on, say, four times the pixels it needs, and the raster is
larger than the 128-pixel size the tool was tuned at, the smallest speck worth keeping
is raised
sixteen-fold (it is an area) and every point and curve is made four times as
expensive to add. Positional precision is relaxed by the same factor only when the
edges are wide as well, because a smooth drawing can survive the round trip without
being oversized at all. At the 128-pixel size the tool was tuned at, and on any raster
whose every pixel carries detail, none of this changes anything. One case had to be fixed
along the way: a single small dot on an almost empty canvas used to pass the round
trip at every size, because the empty canvas made the loss look tiny on average —
the speck limit then rose high enough to erase the dot. The test now also asks that
at most half of the picture's detail is lost, and the dot is drawn.</p>
<p>The second correction is an option. It widens the wobble a boundary point is allowed
by the measured factor, so a curve that would have been accepted on a natively sized
drawing is accepted again at 512 pixels from the same relative position, and it
raises the price of each point to match, as its design says both halves must. It is
off by default. Its help text still warns that it can mistake a small rotated square
for a circle and break a thin ring, though the code's own notes trace those failures
to an older version that judged by image size instead of measuring; the technical
reference lists that as an open question.</p>
</section>
<section>
<h2>When there is nothing solid to measure against</h2>
<p>Stage 2's whole method for reading an edge depends on knowing the two colours a
boundary sits between — a shape's own colour, and whatever is behind it. A
transparent background is not a colour at all, so before tracing starts, every
see-through pixel is written down over something solid.</p>
<p>By default the tool keeps the transparency itself. The picture is written down over
white, but how see-through each pixel was travels alongside it into every step that
reads an edge, and each ink the palette finds carries an opacity of its own. Holes
stay holes and soft shadows stay soft in the finished file, so no backing colour has
to be chosen at all.</p>
<p>That native handling can be switched off, and then the old approach applies: the
picture is painted onto one solid colour before tracing. The obvious choice is white,
and white is exactly wrong for a lot of real artwork.
A white logo on a transparent background, painted onto white, disappears completely —
there is nothing left to trace. A softly translucent panel painted onto white loses
its identity and merges into the background it was meant to sit over.</p>
<p>So the colour used to fill in the transparency is chosen by testing what it would
<em>hide</em>: for each of a short list of candidate colours (white first, then
black, then a few saturated colours real artwork rarely uses), the tool checks how
much of the image's meaningfully-drawn content — the outline of the shape, and any
softly translucent area — would become indistinguishable from that candidate once
painted onto it. The first candidate that would not swallow too much of the real
content wins. A soft glow (opacity that fades gradually, like a light source) gets
no vote either way, because no single flat colour can honestly stand in for
something that was never one flat opacity to begin with.</p>
<p>Even in that mode this choice usually changes nothing visible in the output — the
image is still painted onto plain white — because without an extra flag turned on,
transparency has nowhere to go in the final file anyway: a see-through region gets
painted solid rather than cut out as a hole. The smarter colour choice takes effect
once that flag is on, so the file can be produced for use on a background other than
white. There is one exception: when white would make more than half of the shape's
outline vanish — a white logo on a transparent background — the tool turns that flag
on by itself for that image, because otherwise there would be nothing left to
trace.</p>
</section>
<section>
<h2>Artwork that runs off the edge of the picture</h2>
<p>Tightly cropped logos and stickers often touch the very edge of their canvas. The
tracer used to draw those badly: where a shape met the edge it was cut into pieces
that ended on the border, and those pieces were fitted one by one instead of as the
closed outline the artist drew. A rounded square filling its whole canvas came back
with one corner replaced by a curve stretching halfway along a side.</p>
<p>So when a picture with a transparent background has artwork on its outermost row or
column of pixels, the tool now traces it on a canvas two pixels larger on every side,
the extra pixels left transparent. The artwork then ends inside the canvas, on a
closed outline, and the rounded square comes back as one rounded rectangle. Every
coordinate of the finished file is then moved back by those two pixels, exactly, so
the file has the size and the coordinates of the picture that arrived. The settings
that depend on the picture's size are still worked out from the original size, so a
picture that does not touch its edge traces exactly as before. On the test icons
that touch the edge, the traces came out a fifth closer to the artist's originals at
128 pixels and a tenth closer at 512, with fewer numbers in the file.</p>
</section>
<section>
<h2>Cleaning up genuine damage</h2>
<p>Some input is not merely resized or slightly compressed — it is a screenshot, a
heavily compressed export, or a genuine photograph of a printed logo. For that kind
of damage, there is an optional cleanup step: run the image through a small model
that guesses at extra detail, shrink the result back down, and repaint the flat
areas with the original file's own colours so the tracer is not trusting the model's
colour judgement, only its judgement about where edges should sit.</p>
<p>This step is expensive and not always worth it, so the tool can be told to decide
for itself. In that mode, it traces the file once as it arrived, renders that trace
back into a picture, and compares the two everywhere the trace claims the drawing is
flat. A flat trace that disagrees with the input in supposedly flat territory is a
sign of real damage rather than an honest simplification — a shape that is flat by
construction should not need to argue with a clean input. Below a measured
disagreement threshold, the file is traced as-is. Above it, the cleanup step runs
and the file is traced again. On genuinely clean input, running this cleanup step
anyway makes results roughly three times worse — which is exactly why the tool
checks first rather than always cleaning up "just in case."</p>
<p>The cleanup itself is a separate program that ships beside the tool. If it is not
installed, the deciding mode no longer fails: it keeps the trace it already made,
exactly as it would for a clean file, and says in its report that no cleanup tool
was available. Only asking for the cleanup outright, every time, still stops with an
error when there is nothing to run it with.</p>
</section>
</main>
<nav class="stages">
<a href="00-overview.html">Overview</a>
<a href="01-intake.html" aria-current="page">1 Intake</a>
<a href="02-coverage.html">2 Coverage</a>
<a href="03-palette.html">3 Palette</a>
<a href="04-regions.html">4 Regions</a>
<a href="05-gradients.html">5 Gradients</a>
<a href="06-planar-map.html">6 Planar map</a>
<a href="07-subpixel.html">7 Sub-pixel</a>
<a href="08-boundary-solve.html">8 Boundary solve</a>
<a href="09-decode.html">9 Decode</a>
<a href="10-symmetry.html">10 Symmetry</a>
<a href="11-fitting.html">11 Curve fitting</a>
<a href="12-repair.html">12 Repair</a>
<a href="13-emit.html">13 Emit</a>
<a href="14-fast-mode.html">14 Fast mode</a>
<a href="15-strokes.html">15 Strokes</a>
<a href="constants.md">Constants</a>
</nav>
</div>
</body>
</html>