#contour #boundary #tracing #algorithm #contour_tracing

app raster2svg

A tool that use the contour_tracing library

1 stable release

1.0.10 Sep 10, 2020
1.0.9 Aug 31, 2020
1.0.8 Jul 13, 2020
1.0.7 Jun 12, 2020
1.0.3 Mar 23, 2020

#38 in Images

Download history 17/week @ 2020-06-06 4/week @ 2020-06-13 2/week @ 2020-06-20 8/week @ 2020-06-27 9/week @ 2020-07-04 31/week @ 2020-07-11 15/week @ 2020-07-18 2/week @ 2020-07-25 18/week @ 2020-08-08 18/week @ 2020-08-15 1/week @ 2020-08-22 20/week @ 2020-08-29 40/week @ 2020-09-05 2/week @ 2020-09-12 2/week @ 2020-09-19

54 downloads per month


151 lines

raster2svg crates.io

A tool that use the contour_tracing library Package


  • Support RGB colors + alpha channel (fully transparent colors are not traced)
  • Sort the colors from the most used to the less used
  • Input format: a raster image file
  • Output format: an SVG file

Features from the contour_tracing library: Package

  • Trace contours using the Theo Pavlidis' algorithm (connectivity: 4-connected)
  • Trace outlines in clockwise direction
  • Trace holes in counterclockwise direction


 -s, --size              Add the width, height and viewBox attributes
 -d, --ids               Add the RGB colors and opacity values as id attributes
 -k, --inkscape          Add some Inkscape attributes (transparent background, pixel units, grid, snapping, ...)
 -r, --rendering         Set the shape-rendering attribute at crispEdges
 -c, --closepaths        Close the paths with the SVG Path Z command

 -z, --zoom <PERCENT>    Multiply the width and height attributes by a given percent (e.g. 250)
 -l, --color <COLOR>     Trace only one given color in hexadecimal notation RRGGBBAA (e.g. AABBCC00)
 -i, --input <INPUT>     Input raster image filename (e.g. input.png)
 -o, --output <OUTPUT>   Output SVG filename (e.g. output.svg)

An example with some transparent colors

C:\>raster2svg.exe -s -d -k -r -i rust_input.png -o rust_output.svg
  • rust_input.png: rust_input.png

  • rust_output.svg: rust_output.svg

(click on it to view the source)

An example of a zoom by 800%

(Thanks Nayuki for your QR Code generator)

C:\>raster2svg.exe -s -z 800 -k -r -i qrcode_input.png -o qrcode_output.svg
  • qrcode_input.png: qrcode_input.png

  • qrcode_output.svg: qrcode_output.svg

(click on it to view the source)


  • Be careful with the size and complexity of your input image because the SVG file size grows rapidly...
  • An already compiled executable is available for Windows on GitHub: https://github.com/STPR/raster2svg/releases


raster2svg https://github.com/STPR/raster2svg

Copyright (c) 2020, STPR - https://github.com/STPR

SPDX-License-Identifier: EUPL-1.2


Your contribution is highly appreciated. Do not hesitate to open an issue or a pull request. Note that any contribution submitted for inclusion in the project will be licensed according to the terms given in LICENSE.txt.


~55K SLoC