SVG path data transformation toolkit
A tool and a library for SVG path data transformations. Currently it supports a translation and a scaling.
Usage
As a Python library
import svg_path_transform as S
path = S.parse_path("m 2 2 l 2 2")
path = S.translate_and_scale(path, s=(1, 3))
path = S.translate_and_scale(path, t=(3, 4))
path = S.morph(path, lambda p: [p[0] * 2, p[1] * 2])
print(S.path_to_string(path, sfig=4))
As a command line tool
svg_path_transform --dx 100 --dy 100 <<< "m 2 2 l 2 2"
Command line parameters
usage: svg_path_transform [-h] [--dx N] [--dy N] [--sx N] [--sy N] [--sfig N] [--ndig N] [--seg N] [--pretty-print] [-v]
SVG path data transformer
options:
-h, --help show this help message and exit
--dx N translate x by N
--dy N translate y by N
--sx N scale x by N
--sy N scale y by N
--sfig N round to N significant figures
--ndig N round to N decimal places
--seg N convert to straight line segments with a given max distance
--pretty-print pretty print the input path and exit
-v, --version show program's version number and exit
Hint: a bash function to transform an SVG with a single path inside
function svg_transform() {
selector='//_:path[1]/@d'
input=$(</dev/stdin)
old_path="$(xmlstarlet sel -t -v "$selector" <<< "$input")"
[[ $? -ne 0 ]] && echo "could not parse SVG" && return 1
new_path="$(svg_path_transform "$@" <<< "$old_path")"
[[ $? -ne 0 ]] && echo "could not parse path" && return 1
xmlstarlet ed -u "$selector" -v "$new_path" <<< "$input"
[[ $? -ne 0 ]] && echo "could not update SVG" && return 1
return 0
}
svg_transform --sx 2 --sy 2 < intput.svg > output.svg
Installation
pip install svg_path_transform
Metadata
Release files for svg-path-transform 2.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| svg_path_transform-2.0.2.tar.gz | 10.1 kB | Without provenance | Details for svg_path_transform-2.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| svg_path_transform-2.0.2-py3-none-any.whl | Python 3 | none | any | Details for svg_path_transform-2.0.2-py3-none-any.whl |
Total release size: 21.6 kB
Release files / svg_path_transform-2.0.2.tar.gz
| Download URL | svg_path_transform-2.0.2.tar.gz |
|---|---|
| Size | 10.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c2e432f9a79f0551c9069e964df0c404136851fec9119dd4ac2a08e4bb3e22d7
|
|
BLAKE2b-256 checksum How to use checksums |
98402115ead79510ee78cd7cb86eef90b1c848ff8247e43bb1f5c436bab4ccca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Release files / svg_path_transform-2.0.2-py3-none-any.whl
| Download URL | svg_path_transform-2.0.2-py3-none-any.whl |
|---|---|
| Size | 11.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
283e7856f2731baccecf58d13e947bd8c06408c8e149f46f31980738e56a5f70
|
|
BLAKE2b-256 checksum How to use checksums |
5e5c07167c46eb10469bf5a7e6913f6ec43d079b9b766f3127429b9384bc3a54
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Security for svg-path-transform 2.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.