How it works

One SVG goes in and five files come out, six with a manifest. The same code runs every step on the command line, in the Vite and Astro integrations, and on this site.

1. The SVG stage

favseed checks that the file holds an <svg> element, then optimises it with SVGO. CSS custom properties are resolved first: var(--brand, #0E7C68) becomes its fallback unless you set --var brand=…. The renderer has no var() support and would draw the whole mark black, so a var() with neither a fallback nor a value is an error rather than a black square.

Animation, styling and accessibility survive by default: CSS and SMIL animation, the classes and ids something references, role, and the ids that ARIA attributes name. A @media (prefers-color-scheme: dark) block stays too, so a favicon drawn for dark tab strips keeps working. The result is one icon.svg for the favicon link and for images on your pages. --no-animation writes a static SVG instead.

Coordinates are rounded to as few decimals as the mark allows. favseed tries 1, 2, 3, 4, 6 and 8 decimals in turn and keeps the first whose static render at 512 px has at most 1% of pixels off by more than 8/255, on a black and on a white background. If none passes, icon.svg keeps the source's own numbers and the build warns. A wide or tall viewBox keeps its proportions: the rasters centre it on a square canvas, and icon.svg keeps the original viewport.

2. Placement in the safe zone

Android, ChromeOS and macOS show an installed web app's icon through a shape of their own: a circle, a squircle, a rounded square. Windows and Linux draw it as it is. The W3C Web App Manifest names the area every one of those masks shows, a circle centred on the icon with a radius of 40% of its size. iOS's rounded square contains that circle whole, so the apple-touch-icon and the manifest icons are all placed the same way.

With --padding auto, the default, favseed renders the mark at each icon's own size, finds the opaque pixel farthest from the centre, and scales the mark until that pixel's outer corner sits on the safe circle. A mark drawn with its own margin is enlarged and one that reaches its corners is shrunk. No fixed percentage suits every shape: across the test fixtures auto chooses between 7.6% and 18.8% per side. A number, such as --padding 12, is applied as given.

An exact fit scales by an arbitrary factor, which puts the edges of a mark drawn on a grid between pixels. So favseed then walks the size down in whole pixels, by up to 10%, and takes the size with the fewest partly covered pixels, if that at least halves them. On a seven-block grid mark at 512 px the box goes from 330 to 320 px, the colours from 12 to 3, and the file from 571 to 290 bytes. A curved mark, anti-aliased at every size, keeps its exact fit. A source that is opaque in all four corners is full-bleed and is used as drawn.

The padded icons sit on the --bg ground, #000000 unless you choose another. That is what iOS composites a transparent icon onto anyway, and a maskable icon has to be opaque, so a colour with transparency is refused. --bg none keeps the whole set transparent: the numbered icons are then unpadded and declared any only, while the apple-touch-icon is still placed in the safe zone. The ICO is never padded.

3. Each raster against the accuracy bar

Each raster is rendered at its own size and scored against an unquantised render of your source, placed exactly like it. It passes when at most 1% of pixels are off by more than 8/255 in any channel, and the edge-weighted luma error is at most 1.5883, on both a black and a white background. The second clause catches serrated edges that the first lets through.

The candidates are quality 40, 50, 60, 70, 80, 90, 95, 98 and 99 at the full palette, and quality 100 at 2 to 256 colours: 26 encodes. Each one is already the smaller of a quantised and a lossless PNG. The effort decides how many are tried:

EffortEncodesZopfli
fastOne encode at quality 80 with the full 256-colour palette. Nothing is scored.none
defaultA binary search of each list: 7 to 9 encodes, the smallest that passes.15 iterations
maxAll 26 candidates, the smallest that passes.120 iterations

If quality 80 fails and another candidate passes, that candidate wins even when it is larger: the bar is a constraint, not one side of a trade. If nothing passes, as on the 48 px ICO of a very dense grid, the raster keeps the quality-80 encode. A pinned --quality or --colors makes one encode at that setting and warns when it misses the bar. The Vite and Astro dev servers always use fast.

4. Finishing and packing

Zopfli re-deflates each chosen PNG once, after the choice, so it never runs on a losing candidate. It is lossless: the decoded pixels are unchanged. The order matters, because the quantiser re-encodes from scratch and would throw away any recompression done before it. Measured at 192 px, the wrong order is 21.0% bigger.

favicon.ico is a 22-byte header followed by the 48×48 PNG, unchanged. favseed writes that header itself, byte-identical to icotool -c -r; the BMP payload icotool writes by default is 8.8 times larger on the fixtures. The optional manifest lists only the padded PNGs, and the build prints the <link> tags for your <head>. Outputs describes every file and the markup it needs.

Where it runs

The command line needs Node 24 or newer. Its image engine, @napi-rs/image, carries resvg, oxipng and a quantiser in one native module, prebuilt for Linux, macOS and Windows on x64 and arm64, and FreeBSD on x64. Zopfli is a WebAssembly build of Google's source. The Vite plugin and the Astro integration run the same build and cache its result, keyed on favseed's version, the source, the options and the engine versions.

This site runs the same pipeline in a worker, on the WebAssembly build of the same engine. It needs HTTPS or localhost, WebAssembly and DecompressionStream. Where the browser allows shared memory it uses the threaded engine, and otherwise a single-thread build that is slower but gives the same files. The engine is about 5.7 MB before transfer compression and loads only once you point at, focus or drag onto the file picker. Your file never leaves the tab.

Matching self-contained SVGs and options give identical bytes everywhere. CI builds the test fixtures on Linux, macOS and Windows and compares the hashes, and runs this site in Chromium, Firefox and WebKit against the native output. Outline text and embed images as data: URLs, because fonts and external files can differ between machines. Every number above comes from a measurement; the benchmarks collect the results, and the decisions record why each step is the way it is.

Why each step is this way

Each step was chosen by measurement. docs/DECISIONS.md records the decisions in force and the ones they replaced, and docs/BENCHMARKS.md holds the reproducible sweeps.

One engine, nothing to install. @napi-rs/image bundles the resvg and oxipng versions favseed was measured with, and its renders match the resvg CLI pixel for pixel. Against the native pipeline of resvg, pngquant and oxipng it replaced, the earlier engine comparison found it 9% smaller on a gradient and 0.46% larger across nine flat marks (decision 26). Writing the ICO header in favseed removed the only dependency with no npm package and no Windows build.

The search pays for itself. At the default effort, over 568 rasters, the smallest passing candidate came to 20.4% fewer bytes than quality 80, within 0.2% of trying all 26 (decision 29).

Concurrency is bounded. Raster jobs and complete alignment searches overlap, but a shared scheduler limits the canvas work in flight, starts the largest job first, keeps large custom sizes serial, and drains active work after a failure before returning. Zopfli runs in two workers of its own, in Node and in this page, so one file's compression never holds up another's search (decision 34). Candidate selection and output order stay deterministic.

Placement probes are bounded too. A small mark still enlarges into its safe zone, but searches over large transparent margins render on canvases of the target size, and other probes stay within twice the target size, so ordinary renders can still be reused. The full candidate walk remains: this bounds each probe, not the number of probes or the memory the process uses. The placement report has the measurements.

On a square raster canvas, transparent exports of a wide or tall mark keep transparent bands, and opaque PNGs use your ground and the safe-zone fit. The framing report records the raster proportions, bytes and timings. The precision report records the SVG rounding policy and the matched Vite PWA comparison. The rounding check covers the static base appearance before PNG quantisation; it is not a guarantee for every display size, animation frame or media state.