Skip to main content

logo for vectorify

Convert raster images (PNG, JPG, etc.) into simplified SVG vector graphics using k-means colour quantization and contour tracing.

Installation

Requires Python 3.11+.

uv sync

Usage

uv run vectorify generate <filepath> <output> [options]

Example

uv run vectorify generate photo.png ./output.svg --n_colors 8 --smooth 2 --simplify 0.5

Update README images

Regenerate all example SVGs, PNGs, and grid images used in this README:

uv run vectorify update-readme

Arguments

Argument Type Description
filepath string Path to the input image
out_dir string Directory for the output SVG

Options

Option Type Default Description
--n_colors int 8 Number of colours to quantize the image into
--median_size float 5 Median filter kernel size for label smoothing (0 = disabled)
--min_region float 50 Minimum connected region size in pixels (0 = disabled)
--smooth float 2 Gaussian smoothing sigma applied to contours (0 = disabled)
--simplify float 0.5 RDP simplification epsilon in pixels (0 = disabled)
--buffer float 1 Outward normal offset to expand shapes and fill gaps

Configuration

buffer

Expands each shape outward along its edge normals by the given pixel amount. Eliminates sub-pixel gaps between adjacent colour regions caused by smoothing or simplification.

buffer example


median_size

Applies a median filter of this kernel size to the label map. Fills small holes, removes straggler pixels, and smooths region boundaries. Larger values produce more aggressive cleanup.

median_size example


min_region

Removes connected components smaller than this many pixels, replacing them with their most common neighbouring colour. Catches isolated specks that the median filter misses.

min_region example


n_colors

Number of distinct colours the image is quantized into via k-means clustering. Lower values produce a more simplified, poster-like result.

n_colors example


simplify

Epsilon value for the Ramer-Douglas-Peucker algorithm. Reduces the number of vertices in each contour path. Higher values = fewer vertices = simpler shapes.

simplify example


smooth

Gaussian smoothing sigma applied to contour vertices. Rounds off jagged pixel-aligned edges into flowing curves. Applied before simplification.

smooth example

Metadata

Release files for vectorify 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vectorify 0.1.3
File Size Uploaded Provenance
vectorify-0.1.3.tar.gz 5.3 MB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for vectorify 0.1.3
File Interpreter ABI Platform
vectorify-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 5.4 MB

Release files / vectorify-0.1.3.tar.gz

Download URL vectorify-0.1.3.tar.gz
Size 5.3 MB
Tags Source
SHA-256 checksum
How to use checksums
53ae8b0e1584a75835d250a44b6bb4834b87c87c152ffe61c43980006e2b4c5a
BLAKE2b-256 checksum
How to use checksums
ed5daba7ae57c6d81975ef83f31bbc7e9d3f78c6f29d8374f7cd2dc3a358502e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.3

Release files / vectorify-0.1.3-py3-none-any.whl

Download URL vectorify-0.1.3-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cfc93d7813be6cce8cece54597003e0a924d2f6282ba6b0dba13d41183f985c3
BLAKE2b-256 checksum
How to use checksums
81e238a009a6889da7abfe41d475abc67ad124e7a3cfa3806b6a18fc5f5b907c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.3

Security for vectorify 0.1.3

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page