• This repository has been archived on 30/Oct/2021
  • Stars
    star
    1,621
  • Rank 28,864 (Top 0.6 %)
  • Language
    Rust
  • License
    GNU General Publi...
  • Created almost 13 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

svgcleaner could help you to clean up your SVG files from the unnecessary data.

svgcleaner build status

svgcleaner helps you clean up your SVG files, keeping them free from unnecessary data.


Purpose

The main purpose of svgcleaner is to losslessly reduce the size of an SVG image, created in a vector editing application, before publishing.

Usually more than half of an SVG image's data is useless for rendering. For example:

  • Temporary data used by the vector editing application
  • Non-optimal SVG structure representation
  • Unused and invisible graphical elements

... Are all unnecessary in a published SVG.

Goals

  1. Correctness - svgcleaner should not break an SVG file
  2. Cleaning ratio - Higher is better
  3. Performance - An average SVG file processing time should be closer to ~1ms on a modern PC

Alternatives

In addition to the main advantages of svgcleaner — like correctness, cleaning ratio and performance, which are described below — there are some more nuances to be aware of:

  1. svgcleaner cleans only one SVG file. It doesn't process SVGZ files. It doesn't process directories. It doesn't do anything else. Just one task*.
  2. svgcleaner is strictly lossless by default. There are no destructive cleaning options enabled by default.
  3. svgcleaner is portable. You can build it into a single executable without any external dependencies.

* You can get all of these features using the GUI.

Charts

See Testing notes for details.

All stats were collected using the latest release version.

Correctness

Less is better.

Cleaning ratio

More is better.

* scour creates bigger files (-18.78%).

Cleaning time

Less is better.

Other

Collection Size Before (MiB) Size After (MiB) Ratio (%)
Breeze icons theme 21.72 11.09 48.91
Ardis icons theme 11.82 5.23 55.74
Humanity icons theme 8.56 3.08 64.01
Open Icon Library 207.45 69.44 66.53
Elementary icons theme 17.72 7.09 59.95
Adwaita icons theme 2.21 0.37 83.08
Faience icon theme 22.35 11.14 50.16
GCP Icons 0.344 0.082 75.9

Documentation

Documentation can be found here.

Limitations

svgcleaner shouldn't change your file unless you tell it to, but there are still things that can't be preserved. So even if you disable all cleaning options there are still things that will be changed, such as:

  • Original indent is not preserved
  • All colors will be formatted as #RRGGBB and #RGB
  • DOCTYPE, CDATA will be processed and removed
  • CSS support is minimal
  • CSS from the style element will be extracted and processes. The style element will be removed.
  • The style attribute will be split into attributes
  • The class attribute will be processed and removed
  • Paths and transformations will be reformatted
  • currentColor and inherit attributes values will be resolved
  • Referenced elements will be moved to the defs element
  • IRI and FuncIRI attributes that reference non-existing objects will be removed
  • If the offset attribute value of the stop element is represented as percentage - it will be converted into a decimal number

Usage

CLI

svgcleaner in.svg out.svg

Change default options:

svgcleaner --indent=2 --paths-coordinates-precision=5 --join-arcto-flags=yes in.svg out.svg

Use --help for a list of the cleaning options and see the documentation for more details.

GUI

You can get a GUI here.

Downloads

You can get prebuilt packages here.

Building

Dependency: Rust

cargo build --release

If you're a Rust programmer, you can install svgcleaner using:

cargo install svgcleaner

Contributing and Issues

See CONTRIBUTING.md for details.

FAQ

See FAQ.md for details.

License

svgcleaner is licensed under the GPL-2.0.

More Repositories

1

resvg

An SVG rendering library.
Rust
2,684
star
2

cargo-bloat

Find out what takes most of the space in your executable.
Rust
2,295
star
3

tiny-skia

A tiny Skia subset ported to Rust
Rust
1,089
star
4

ttf-parser

A high-level, safe, zero-allocation TrueType font parser.
Rust
609
star
5

pico-args

An ultra simple CLI arguments parser.
Rust
560
star
6

rustybuzz

A complete harfbuzz's shaping algorithm port to Rust
Rust
533
star
7

roxmltree

Represent an XML document as a read-only tree.
Rust
428
star
8

svgcleaner-gui

GUI for svgcleaner.
C++
306
star
9

fontdb

A simple, in-memory font database with CSS-like queries.
Rust
136
star
10

xmlparser

A low-level, pull-based, zero-allocation XML 1.0 parser.
Rust
130
star
11

color-thief-rs

Grabs the dominant color or a representative color palette from an image.
Rust
75
star
12

svgtypes

A collection of parsers for SVG types.
Rust
67
star
13

rctree

A "DOM-like" tree implemented using reference counting
Rust
37
star
14

simplecss

A simple CSS 2.1 parser and selector
Rust
35
star
15

svgdom

Library to represent an SVG as a DOM.
Rust
31
star
16

ttf-explorer

A simple tool to explore a TrueType font content as a tree
C++
30
star
17

xmlwriter

A simple, streaming XML writer.
Rust
24
star
18

resvg-test-suite

resvg test suite
C++
23
star
19

svgparser

(DEPRECATED) Featureful, pull-based, zero-allocation SVG parser.
Rust
22
star
20

notes-on-svg-parsing

Notes on SVG parsing
21
star
21

barh

A simple horizontal bar chart generator.
Rust
9
star
22

strict-num

A collection of bounded numeric types.
Rust
8
star
23

unicode-vo

Unicode vertical orientation detection
Rust
6
star
24

unicode-ccc

Unicode Canonical Combining Class detection
Rust
4
star
25

unicode-bidi-mirroring

Unicode Bidi Mirroring property detection
Rust
3
star
26

RazrFalcon

2
star
27

stb_truetype_meson

C
1
star