Convert an image or SVG into a padded polygon hull for CSS shape-outside / text-wrap.
Project description
ipolypad
Convert an image or SVG into a padded polygon hull suitable for CSS
shape-outside and HTML/canvas text-wrap engines. Reference implementation.
See the project root README.md and SPEC.md for
the full design. This package is the Python side — smart, batteries-included,
multi-format output.
Install
uvx ipolypad trace dragon.svg --pad 6 --max-points 32 --out dragon.json
# or
uv pip install ipolypad
CLI
ipolypad trace <src> [--size 200] [--pad 6] [--max-points 32] \
[--hull / --no-hull] [--format json,css,svg,png,html] \
[--enhance / --no-enhance] [--bg-tolerance 12] \
[--selector .figure] [--out path]
ipolypad batch '*.svg' --out-dir dist/ [trace options...]
src may be a local path, an http(s):// URL, or a data: URL.
Library
from ipolypad import trace
result = trace("dragon.svg", size=200, pad=6, max_points=32, format="json")
print(result["points"])
Output
Default JSON:
{
"src": "dragon.svg",
"raster": { "width": 200, "height": 200, "pad": 6 },
"max_points": 32,
"n_points": 18,
"points": [[0.500000, 0.020000], ...]
}
points are normalized 0..1 against the rasterization box, six decimals,
no trailing closing vertex (polygon is implicitly closed).
License
Apache-2.0. See LICENSE.
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
File details
Details for the file ipolypad-1.0.1.tar.gz.
File metadata
- Download URL: ipolypad-1.0.1.tar.gz
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a087515bbe7aa61531ba7177dc7c080b4eeb3292ebcd05e17106dda684b5ef17
|
|
| MD5 |
cf9a28babaceaf593cdc8860c15feaea
|
|
| BLAKE2b-256 |
33381ce7be4f64152bffeafac4fc4f5a66f3317aa33e9c2504fe6940cd6afeab
|