Skip to main content

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. Positive padding dilates the silhouette; negative padding erodes it.

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

ipolypad-1.0.5.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

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

ipolypad-1.0.5-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file ipolypad-1.0.5.tar.gz.

File metadata

  • Download URL: ipolypad-1.0.5.tar.gz
  • Upload date:
  • Size: 13.0 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

Hashes for ipolypad-1.0.5.tar.gz
Algorithm Hash digest
SHA256 5bf7dcf743c80c83f5248fcef46fb455649443c0ca87c2be102af27b2648afe7
MD5 6a6c01cbec2cd136811ed5588604a37a
BLAKE2b-256 f6ce6008484b0087c5fa12eee6507112a72fe6c98bd6d961161054663442027e

See more details on using hashes here.

File details

Details for the file ipolypad-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: ipolypad-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • 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

Hashes for ipolypad-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 7f804f5c021a906a0b0256d7e7e77a7ebd72269ba9cf6ca57946067b13de4187
MD5 ec464418362ea167435f0c98f2a3eb59
BLAKE2b-256 fd20353b6af48aa6b0e37e994c2404f0cc53d771cf899f7739af38370521f16c

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