1
0
Fork
You've already forked SVGIZE
0
No description
  • Rust 90.2%
  • Handlebars 5%
  • Shell 4.8%
Find a file
2026年06月01日 04:38:18 +02:00
assets Smaller readme images 2025年12月15日 10:43:17 -08:00
images Small optimization 2025年08月06日 21:00:38 -07:00
src Bump library versions, fix rand names 2026年02月15日 20:16:49 -08:00
.gitignore Sky rats and japanese streets 2025年07月27日 15:26:07 -07:00
about.hbs Hopefully automated releases.... so RELEASE_NEW! 2025年08月08日 00:36:19 -07:00
about.toml Hopefully automated releases.... so RELEASE_NEW! 2025年08月08日 00:36:19 -07:00
bad_frames.txt Cleanup RELEASE_NEW 2026年02月15日 12:34:43 -08:00
Cargo.lock Bump library versions, fix rand names 2026年02月15日 20:16:49 -08:00
Cargo.toml Bump library versions, fix rand names 2026年02月15日 20:16:49 -08:00
gen_images_png.sh Hopefully automated releases.... so RELEASE_NEW! 2025年08月08日 00:36:19 -07:00
license Licenses 2025年07月27日 15:31:59 -07:00
readme.md Update readme.md 2026年06月01日 04:38:18 +02:00
rust-toolchain.toml Licenses 2025年07月27日 15:31:59 -07:00

SVGIZE

An image filter

Before After
An image of a street in japan at night An image of a street in japan at night
An image of a sky rat An image of a sky rat
An image of portland from the japanese gardens coming soon

The image of the street in japan is licensed under Creative Commons Attribution 2.0 Generic originally posted to Flickr on March 27, 2013 at 9:58:19 AM PDT by whitefield_d
The image of the bird is taken by Wintersys/Vortetty, licensed under CC BY-SA 4.0.
The image of mt. hood and portland is taken by Wintersys/Vortetty, licensed under CC BY-SA 4.0.
All images in the after column were processed using the program from this repository and hold the same licenses as the original images.

The japanese street image is about 10000 images and the skyrat image is about 22000 images. Each image took about an hour to complete. This can of course be sped up, and has been in more recent versions, however the process remains CPU and memory bottlenecked, as the developer dislikes working with GPUs.

In the assets folder is an example svg/toml output as well for the script.


Builds?

My applications are not intended for use in regions requiring any form of age verification, and due to those laws I will not be providing premade builds. For more info see this page


TODO

  • Guide placement by error and thresholding
  • Add output listing mode, to output all images used with paths and modifications for each usage. Useful for SVGs that require attribution
  • Add hd PNG output mode, maybe use resvg? though that imports a skia reimplementation... Would be better than what i have now where you have to manually convert
  • Implement a function to allow better use of the image compare lib, done along with all the yuv overhead
  • Find and fix source of code deadlocks (turned out to be nested rayon calls)
  • Consecutive fails allowed setting to prevent going for an accuracy or number of images that is impossible to reach, 100 seems reasonable?
  • Reuse elements instead of repeating them, these SVG sizes are getting out of control

Usage

Please see Building from scratch

For help with usage, you can run

svgize -h

or refer to below:

Usage: svgize [OPTIONS] <INPUT>
Arguments:
 <INPUT> Input file, supported formats: .jpg, .jpeg, .jpe, .png, .webp, .avif, .bmp, .tiff, .tif, .qoi
Options:
 -o, --output <OUTPUT> Output file, will output in the same folder by default. Should be an svg, if not an svg it will add the extension
 -s, --shapes <SHAPES> Minumum number of shapes to place, depending on the image you may want more than default, set to 0 to disable [default: 500]
 -m, --matchscore <MATCHSCORE> Minimum match percentage (0.0-100.0), if used with --shapes will stop only when both conditions are met, 100% is impossible and normally 25-50% match is enough. If set to 100% it will run until it fails the number of times specified by --failmax [default: 0.0]
 -c, --cmpwidth <CMPWIDTH> Image width to use during comparison of image, larger images will be more similar at the cost of speed, smaller (even 256 or 512) will normally yield a fine result, that said larger images will allow more variation and thus accuracy [default: 384]
 -f, --failmax <FAILMAX> Max number of failed iterations before the image is output as-is. This overrides cmpwidth and matchscore so it will need set very high to work [default: 100]
 -i, --imgcnt <IMGCNT> Number of images to try in each iteration, more will be slower but choose more optimal images and have failed iterations less often [default: 16]
 -p, --png Output is SVG by default, this will make it output a png at 4x the value of --cmpwidth in addition to the svg
 -r, --resolution <RESOLUTION> The width the png output should be, height is auto-calculated based on this. It doesn't go any smaller than 1x1 and will not let any dimension be less than 1 [default: 1536]
 -l, --logedits When enabled, generates a .toml file that lists all edits made to ease compliance with some image licenses. Please see the legal note in the readme for more info, and the file's comment header for even more info. The file is sufficient to recreate the image as well, so may be useful for further processing
 -n, --nosvg When enabled, will prevent the program from outputting an SVG. Could be useful if you wish to use the --logedits output for processing rather than the SVG directly, or only want to get a one-time png without the scalable svg
 -k, --kmeans When enabled, will use k-means clustering to pick the background color. Good for images with high contrast where averages may not be desireable,
 --kmeansiters <KMEANSITERS> Iterations to use for k-means, this will be used both for max iterations of the algorithm, and it's sqrt will determine how many attempts should be made to find a better colour [default: 20]
 --rejectsimilar <REJECTSIMILAR> Chance that placements which are close to the background color should be rejected [default: 50.0]
 -d, --downscalenearest Downscales without interpolation, good for high contrast images
 -h, --help Print help
 -V, --version Print version

The most basic command would just be svgize <image-file-here>, however the defaults produce very abstract images. You may want to use -s 5000 to force 5000 objects or -i 32 to pick more optimal ones each time. The help text explains all of the flags in greater detail.

I would implore anyone using this program to read The legal usage note


Building from scratch

Important note prior to running, please make sure you have rsvg-convert (from librsvg), git, and nasm installed.

Once those are installed, clone the repo

git clone https://github.com/Vortetty/SVGIZE
cd SVGIZE
git submodule init
git submodule update

Next step depends on your OS

Linux/Mac:

run gen_images_png.sh

This does use rm, mkdir, find, and printf. If these are for some reason not present on your system refer to the windows method.

Windows/Others:

You sadly don't have a script to do this right now, but make a copy of images called images_png and convert all of the SVGs to 512x512 PNGs in-place

Lastly, compile

cargo build --release

This will place your executable at target/release/svgize


(click to open)

TL;DR

This program produces derivative images from original source images and SVG inputs, so you must comply with the licenses of both these components. Mixing copyleft or attribution-required licenses among either original images or SVG inputs can create conflicting obligations that may render your output illegal to distribute. Carefully verify all licenses involved. The --logedits option is provided to assist in compliance, and also includes more info, however it is not enough to comply with most licenses.

Reading the full notice is strongly recommended to understand your responsibilities and avoid licensing problems.

This note is not legal advice. If you have questions regarding your specific use case, consult a qualified attorney.


Full Note

This program produces images that are derivative works both of the original source images and all SVG inputs used in the assembly process. Consequently, your output must comply with the copyright licenses of all incorporated materials.

I do not intend to scare away users. Compliance is made as simple as possible, however, it is often underestmated what it requires.

License Compliance

  • We strongly recommend avoiding SVG inputs under copyleft or attribution-required licenses unless you are prepared to comply with those licenses, which may include providing attribution or license texts.
    • If you choose to use such assets, the --logedits flag can generate a TOML file listing every image processed and the modifications made to it, as well as other image info. This log can assist you in meeting obligations such as documenting "state changes," though you may need to perform additional formatting or include other required information to achieve full compliance. It also includes some other info as far as what compliance might entail.
  • All SVGs included with this program are, to the best of our knowledge, public domain or freely licensed without attribution requirements. This assessment is based solely on the licensing information provided by the original source pages; we do not independently verify the validity or accuracy of those licenses.
  • Users are responsible for verifying the license status of any third-party SVGs they incorporate and ensuring compliance with those licenses.
  • Important: Combining multiple inputs (both source images and SVGs) under differing copyleft licenses can create conflicting licensing obligations that may render your resulting image illegal to distribute under any license. Copyleft terms often cannot be simultaneously satisfied across incompatible licenses. Therefore, please carefully vet all SVGs you use to avoid such conflicts and ensure compliance.

Disclaimer

This note is not legal advice. If you have questions regarding your specific use case, consult a qualified attorney.

Reporting Issues

If you believe any included SVGs violate your copyright or licensing terms, please report an issue on the codeberg page. We will make all reasonable efforts to resolve concerns promptly upon notification and, if necessary, assist in connecting you with appropriate contacts for escalation.