Skip to content

ahaoboy/osvg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages