loicland / img2svg

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

img2svg

Approximates images in svg format. Now supports Bezier curves!

input image output svg (polygonal)

1. Cloning

Use the recursive submodule option to clone the necessary submodules.

git clone --recurse-submodules https://github.com/loicland/img2svg

Otherwise, clone the following repo in the root:

2. Requirement

You need numpy, matplotlib

pip install numpy matplotlib

3. Installation

In a command prompt run:

python setup.py build_ext

Test with

python img2svg.py

4. Usage

python img2svg -f filename -r reg_strength -c contour_color -s stroke_width -o out_size -p output_path

With

  • -f --file: path to image
  • -r --reg_strength : how much simplification to do. Default = 1.0
  • -c --contour_color: color of the contour, if any. Default = '' (no contour). Exemple : 'red'
  • -s --stroke_width: width of the contour (only if contour_color != ''). Default = 2.0 (thick)
  • -o --out_size: size of the largest side of the image. Default = 500
  • -p --output_path: output path. Default = replace the image extension by `svg`
  • -a --apply: Function to apply before partition: sqrt, log, none (default)
  • -s --smooth: Smoothing term. 0 = polygonal, >0 cubic Bezier curves. Default = 1.0
  • -lt --line_tolerance: How far are lines allowed to deviate from the borders. Default = 1.0
  • -ct --curve_tolerance: max difference area ratio diff between original and simplified polygons. Default=0.2

About

License:GNU General Public License v3.0


Languages

Language:Python 100.0%