| Crates.io | svg-optimizer |
| lib.rs | svg-optimizer |
| version | 1.0.0 |
| created_at | 2025-03-08 01:04:35.967603+00 |
| updated_at | 2025-03-08 01:04:35.967603+00 |
| description | SVG file optimizer |
| homepage | |
| repository | https://github.com/Pavi1on-Mk-Git/svg-optimizer |
| max_upload_size | |
| id | 1583866 |
| size | 142,371 |
First, setup Rust and Cargo according to the official instruction.
To use commands defined in justfile, install Just.
From the main directory of the project, compile and run the project via just run ARGS or just run-release ARGS. Replace ARGS with command line arguments for the program.
Example: just run examples/rect.svg should create an optimized examples/opt_rect.svg file.
You can pass -o flag to set the names of the output files, like so:
just run examples/rect.svg -o examples/rect2.svg
By default, all optimizations except lossy ones are enabled. To disable each of them, a flag is available, for example:
just run examples/rect.svg --no-shorten-ids
You can also disable all optimizations by default with -d and only enable a select few; for example:
just run examples/rect.svg -d --shorten-ids --remove-attribute-whitespace
Lossy optimizations need to be explicitly enabled. The flags to achieve this are --merge-transforms and --round-floats. Precision of the floating-point numbers that they output is controlled by the --precision flag; by default it is set to 3.
Description of each flag is available after running just run --help.