osvg

Crates.ioosvg
lib.rsosvg
version
sourcesrc
created_at2024-09-07 04:34:39.852794
updated_at2024-10-19 04:11:30.983492
descriptionosvg svgo
homepagehttps://github.com/ahaoboy/osvg
repositoryhttps://github.com/ahaoboy/osvg
max_upload_size
id1366927
Cargo.toml error:TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
阿豪 (ahaoboy)

documentation

README

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
Commit count: 7

cargo fmt