4 releases

0.1.3 Oct 19, 2024
0.1.2 Oct 19, 2024
0.1.1 Oct 17, 2024
0.1.0 Sep 7, 2024

#192 in Compression

Download history 134/week @ 2024-09-01 34/week @ 2024-09-08 24/week @ 2024-09-15 8/week @ 2024-09-22 6/week @ 2024-09-29 447/week @ 2024-10-13 280/week @ 2024-10-20 67/week @ 2024-10-27 3/week @ 2024-11-03

797 downloads per month
Used in ansi2

MIT license

1MB
280 lines

A wrapper library using rquickjs and svgo to compress svg in environments that do not support node and deno

install

cargo binstall osvg
or
cargo install osvg --features=cli

usage


osvg ./input.svg ./output.svg

config

Pass the svgo configuration object as a string

let s = osvg(&svg, Some(r#"
{
  plugins: [
    {
      name: "preset-default",
      params: {
        overrides: {
          cleanupIds: false,
          inlineStyles: false,
          // minifyStyles: false,
        },
      },
    },
  ],
}
"#)).unwrap();

perf

hyperfine --shell fish 'svgo ./bench.svg -o ./b.svg' 'osvg ./bench.svg ./b.svg'
Benchmark 1: svgo ./bench.svg -o ./b.svg
  Time (mean ± σ):     591.6 ms ±   9.9 ms    [User: 399.4 ms, System: 246.6 ms]
  Range (min … max):   579.1 ms … 603.5 ms    10 runs

Benchmark 2: osvg ./bench.svg ./b.svg
  Time (mean ± σ):      3.328 s ±  0.029 s    [User: 3.165 s, System: 0.126 s]
  Range (min … max):    3.282 s …  3.368 s    10 runs

Summary
  svgo ./bench.svg -o ./b.svg ran
    5.63 ± 0.11 times faster than osvg ./bench.svg ./b.svg

Dependencies

~7–10MB
~238K SLoC