Skip to main content

Rust SVG path editing, optimization, matrix geometry, measurement, sanitization, viewport editing, validation, tracing, and centerline reconstruction with Python bindings.

Project description

svgo

svgo is now implemented in Rust. The Python package is a thin PyO3-backed binding layer, and all SVG/path/tracing/centerline work is delegated to the native svgo._svgo extension. A Rust svgo binary target is also provided for CLI use.

The project intentionally does not preserve the old pure-Python internals.

What It Does

  • Parses, serializes, transforms, reverses, re-origins, optimizes, and converts SVG path data.
  • Optimizes SVG documents with built-in SVGO-style cleanup passes.
  • Converts basic SVG shapes to paths, flattens transforms, inlines styles, sanitizes unsafe content, edits viewBox/viewport data, and reports metadata.
  • Measures path/SVG bounds, lengths, and point-at-length coordinates.
  • Traces simple PNG icons into SVG paths in Rust.
  • Provides VTracer-style tracing controls through the native Rust tracer.
  • Reconstructs approximate centerline strokes from filled outlines with a Rust rasterize/skeletonize/trace pipeline.

Layout

  • rust/src/lib.rs: Rust implementation plus PyO3 exports.
  • rust/src/bin/svgo.rs: Rust CLI binary target.
  • src/svgo/*.py: thin Python shims and dataclass option wrappers.
  • tests/: Python tests that exercise the Rust-backed package surface.

Build

Use uv for Python commands.

uv run --no-project --with maturin maturin build --manifest-path Cargo.toml --out dist

On Windows, the GNU build used during local verification required:

  • Rust toolchain: stable-x86_64-pc-windows-gnu
  • MinGW/binutils on PATH (dlltool, linker runtime DLLs)

The Rust binary can be built directly:

cargo build --bin svgo

Test

uv run --no-sync python -m unittest discover -s tests

Python API

The familiar top-level imports remain as thin wrappers:

from svgo import PathData, optimize_svg, path_metrics, trace_png

path = PathData.parse("M0 0H10V10Z")
path.apply_operation("translate:2,3")
print(path.to_string(decimals=2, minify=True))

Those wrappers perform marshaling only. The computation happens in Rust.

CLI

The Rust binary target supports the existing short command family:

target\debug\svgo.exe path --path "M10 10h5v5z" --op optimize:safe --minify
target\debug\svgo.exe opt --input icon.svg --output icon.min.svg
target\debug\svgo.exe trace --input icon.png --output traced.svg
target\debug\svgo.exe center --path "M0 0L30 0L30 6L0 6Z" --emit d

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

svgo-0.2.0.tar.gz (62.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

svgo-0.2.0-cp312-cp312-win_amd64.whl (703.0 kB view details)

Uploaded CPython 3.12Windows x86-64

svgo-0.2.0-cp312-cp312-manylinux_2_28_x86_64.whl (862.1 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

svgo-0.2.0-cp312-cp312-manylinux_2_28_aarch64.whl (826.7 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

svgo-0.2.0-cp312-cp312-macosx_11_0_arm64.whl (762.9 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

svgo-0.2.0-cp312-cp312-macosx_10_12_x86_64.whl (802.1 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

svgo-0.2.0-cp311-cp311-win_amd64.whl (706.7 kB view details)

Uploaded CPython 3.11Windows x86-64

svgo-0.2.0-cp311-cp311-manylinux_2_28_x86_64.whl (867.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

svgo-0.2.0-cp311-cp311-manylinux_2_28_aarch64.whl (830.9 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

svgo-0.2.0-cp311-cp311-macosx_11_0_arm64.whl (769.2 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

svgo-0.2.0-cp311-cp311-macosx_10_12_x86_64.whl (800.6 kB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

File details

Details for the file svgo-0.2.0.tar.gz.

File metadata

  • Download URL: svgo-0.2.0.tar.gz
  • Upload date:
  • Size: 62.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for svgo-0.2.0.tar.gz
Algorithm Hash digest
SHA256 4510a1b97dfb0550acb8e471e427f87b6314f477d0ede506c406fbe5648425d6
MD5 fe148ea4d4995351191d079850ab320c
BLAKE2b-256 8fb3c0e90743c6af4f6be86740c3a9c529202b3f4f1ee3a11e7058f9af1a0c52

See more details on using hashes here.

Provenance

The following attestation bundles were made for svgo-0.2.0.tar.gz:

Publisher: publish.yml on xmodar/svgo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file svgo-0.2.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: svgo-0.2.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 703.0 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for svgo-0.2.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 71bdb60f257c49a183d2b68509564d94a6bd30a1e754ea8772c9e790547f0756
MD5 d4980c41b9739c173c2c46debf4579d5
BLAKE2b-256 f454dfc22828a34c532f36d96cdbff054dec90d63357107bf835d5d12ca5d856

See more details on using hashes here.

Provenance

The following attestation bundles were made for svgo-0.2.0-cp312-cp312-win_amd64.whl:

Publisher: publish.yml on xmodar/svgo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file svgo-0.2.0-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for svgo-0.2.0-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 52fa71228c8ec38f3276a326dae813eb53560f725a468af3bf3abe7892d41f74
MD5 379c50fff2e52c4b751b1d4d50a59516
BLAKE2b-256 c14d73eb64e37d89d408e2a15d1fd906013db71f88e564f218b7b93810e60572

See more details on using hashes here.

Provenance

The following attestation bundles were made for svgo-0.2.0-cp312-cp312-manylinux_2_28_x86_64.whl:

Publisher: publish.yml on xmodar/svgo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file svgo-0.2.0-cp312-cp312-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for svgo-0.2.0-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 43cedbcbc4660b0b8b47cbbdb093edcd14a8efbeb0e09e2384987f58075de778
MD5 82909c64078f339762a256b840311fb3
BLAKE2b-256 036e95527d061b949c94f7f6eb50bab534f036c38def6915f390738eeff3045b

See more details on using hashes here.

Provenance

The following attestation bundles were made for svgo-0.2.0-cp312-cp312-manylinux_2_28_aarch64.whl:

Publisher: publish.yml on xmodar/svgo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file svgo-0.2.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

  • Download URL: svgo-0.2.0-cp312-cp312-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 762.9 kB
  • Tags: CPython 3.12, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for svgo-0.2.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 77279aeab2b84af0135f56d719028631b193bb237b872031e7f9f869f6e23317
MD5 8ab46970b970150074083bd1d9d36db5
BLAKE2b-256 c91dbc7b704ce0ae5aaea67fda876931caa39a4249ee3509191f85098970f095

See more details on using hashes here.

Provenance

The following attestation bundles were made for svgo-0.2.0-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: publish.yml on xmodar/svgo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file svgo-0.2.0-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for svgo-0.2.0-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 dc14ac821a111b598a2268c8a8e6a7510b7975ec376f2e38c73ff8dd30d7d9c4
MD5 960565f679a6485a0f2f6dc7a7fa6d5d
BLAKE2b-256 234aebb14d1efa7e0b2aa21ac214da87f74b94cf2f55a7efba1f07853c262da2

See more details on using hashes here.

Provenance

The following attestation bundles were made for svgo-0.2.0-cp312-cp312-macosx_10_12_x86_64.whl:

Publisher: publish.yml on xmodar/svgo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file svgo-0.2.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: svgo-0.2.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 706.7 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for svgo-0.2.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 3254a38d6ce26bde977eba4f466d2a0332b9261aa18ac8e34e0b0e0a57e6f2f8
MD5 0c96f41c0f2fd8fe68de42b73547d5cd
BLAKE2b-256 ce303d8e0163848a2e37fc7b8d6d6ff665b03f7cd47eee7e6974d0775b0fe987

See more details on using hashes here.

Provenance

The following attestation bundles were made for svgo-0.2.0-cp311-cp311-win_amd64.whl:

Publisher: publish.yml on xmodar/svgo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file svgo-0.2.0-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for svgo-0.2.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 19df937c1231ed31770fb8ef6e073f6ad77eb4b3a425432b0fd7c2f03680b1c5
MD5 2160341498375aebe5cba561ec6aaf26
BLAKE2b-256 7956c0a48b98b4d669ce766f5d64d5c62659897a6b36aa62061c786f19dee8d3

See more details on using hashes here.

Provenance

The following attestation bundles were made for svgo-0.2.0-cp311-cp311-manylinux_2_28_x86_64.whl:

Publisher: publish.yml on xmodar/svgo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file svgo-0.2.0-cp311-cp311-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for svgo-0.2.0-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 74f0abc9f37cacdfe491550a8a9623b9a86ba4ac1f18fbdef1376b779eac64bc
MD5 c44cbacde692f1e5a0b4ef6bbdd54d70
BLAKE2b-256 a8939e0b97c97a42c4c108ffbaef8df8677685bfbb0202400dc1de0f5d024ae8

See more details on using hashes here.

Provenance

The following attestation bundles were made for svgo-0.2.0-cp311-cp311-manylinux_2_28_aarch64.whl:

Publisher: publish.yml on xmodar/svgo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file svgo-0.2.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

  • Download URL: svgo-0.2.0-cp311-cp311-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 769.2 kB
  • Tags: CPython 3.11, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for svgo-0.2.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6559a3dbaa713ec12d9bd59fb78e7536037269b2b6a16785e111bd449b254d22
MD5 fe606e1a4b41847c2ca50c7674a80b49
BLAKE2b-256 534f925e3ae8bbc8628c3701c26901122dd9edd9b6b97a70d5a89e8d8c16f9d9

See more details on using hashes here.

Provenance

The following attestation bundles were made for svgo-0.2.0-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: publish.yml on xmodar/svgo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file svgo-0.2.0-cp311-cp311-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for svgo-0.2.0-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 bc3d728d8d8c3a286d5b0ca2ab528e9132e65a65cca72de48c8926c67b98de98
MD5 98cca74c63f113b4a879666283747dad
BLAKE2b-256 e420b3889a4c3f68f6a6028afd56eee4e58b61f7675bdb84ccbdcf12fd98f61d

See more details on using hashes here.

Provenance

The following attestation bundles were made for svgo-0.2.0-cp311-cp311-macosx_10_12_x86_64.whl:

Publisher: publish.yml on xmodar/svgo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page