svg_optimize
Optimize SVG files by pruning unreferenced defs, stripping Inkscape/Sodipodi/RDF metadata, removing empty groups, rounding coordinates, and minifying to cut file size.
Instructions
REAL SVG optimisation: prune unreferenced defs, strip inkscape:/sodipodi:/RDF cruft, drop empty groups, round coordinates, remove default style properties, minify. Done in Python because Inkscape's own vacuum-defs is a VERIFIED silent no-op headlessly and document-cleanup is window-scoped. Reports bytes saved.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| minify | No | Collapse whitespace and drop comments. | |
| keep_ids | No | Ids that must never be pruned. | |
| precision | No | Decimal places to round coordinates to. | |
| input_path | No | Source file to read. | |
| prune_defs | No | Remove unreferenced entries from <defs>. | |
| output_path | No | File to write. Overwritten if it exists. | |
| strip_metadata | No | Remove inkscape:, sodipodi: and RDF markup. | |
| strip_unused_ids | No | Drop ids nothing references. Off by default: ids may be referenced from outside the file. | |
| drop_empty_groups | No | Remove containers that paint nothing. | |
| strip_default_style | No | Drop style properties that restate the SVG default. |