Skip to main content

An extended fork of Google's picosvg with better real-world SVG compatibility

Project description

picosvgx

An extended fork of Google's picosvg with better real-world SVG compatibility.

Why picosvgx?

picosvg is excellent for font/icon toolchains — it simplifies SVG files down to paths and gradients. But real-world SVG files are messy:

  • They use CSS units (12pt, 100px, 2cm)
  • They miss namespace declarations
  • They contain <filter>, <mask>, <pattern> that you might want to preserve
  • They have edge cases that cause crashes

picosvgx handles these gracefully.

What's Different

picosvg picosvgx
CSS units (pt, cm, mm) Crashes Parsed correctly
Missing SVG namespace Crashes Auto-fixed
<filter>, <mask>, <pattern> Removed Preserved (opt-in)
Empty <clipPath> Crashes Handled
Degenerate transforms Crashes Handled
Nested <text> in <g> Not allowed Supported

Installation

pip install picosvgx

Usage

Python API

from picosvgx.svg import SVG

# Basic usage (same as picosvg)
svg = SVG.parse("input.svg")
result = svg.topicosvg()
print(result.tostring())

# Preserve filters, masks, patterns
result = svg.topicosvg(allow_all_defs=True)

CLI

# Simplify SVG
picosvgx input.svg > output.svg

# Preserve filters, masks, patterns
picosvgx --allow_all_defs input.svg > output.svg

# Allow text pass-through
picosvgx --allow_text input.svg > output.svg

Development

pip install -e '.[dev]'
pytest

Compatibility

picosvgx maintains full API compatibility with picosvg. Drop-in replacement:

# Before
from picosvg.svg import SVG

# After
from picosvgx.svg import SVG

Credits

Based on picosvg by Google Fonts. Original work Copyright 2020 Google LLC.

License

Apache License 2.0. See LICENSE for details.

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

picosvgx-0.1.0.tar.gz (128.4 kB view details)

Uploaded Source

Built Distribution

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

picosvgx-0.1.0-py3-none-any.whl (55.4 kB view details)

Uploaded Python 3

File details

Details for the file picosvgx-0.1.0.tar.gz.

File metadata

  • Download URL: picosvgx-0.1.0.tar.gz
  • Upload date:
  • Size: 128.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for picosvgx-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2108e36cab4dc4f96320c187f583b70eca8d6bc25efb76d97f0c3ee98ce71091
MD5 902d7e9eb319ead49395b679d068f0e9
BLAKE2b-256 b03848db7f2750ebc83db1ed31cd957c529d8219a13937b33f2bef7d4ff3e472

See more details on using hashes here.

File details

Details for the file picosvgx-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: picosvgx-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 55.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for picosvgx-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8fd3560761290f692d7c3f425ccb017572d87fbdcb6fb59cc4ac3f85d2b11846
MD5 942cabb3be991478dd130ccb408007eb
BLAKE2b-256 d1a5e7a74e1608b8fdb6f825b381a14180b8521da1175331b63228d1810ce9d3

See more details on using hashes here.

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