#contour #algorithm #svg #tracing #boundary #graphics #contour-tracing

app 栅格转SVG

使用contour_tracing库的工具

1 个稳定版本

1.0.14 2022年2月21日
1.0.12 2021年8月3日
1.0.11 2021年2月13日
1.0.10 2020年9月10日
1.0.3 2020年3月23日

#178图像

每月 39 次下载

EUPL-1.2

19KB
189

栅格转SVG crates.io

使用contour_tracing库的工具 Package

功能

  • 支持 RGB颜色 + 透明通道(完全透明的颜色不会被追踪)
  • 按使用频率从高到低排序颜色
  • 输入格式:位图图像文件
  • 输出格式:SVG文件

contour_tracing库的功能:Package

  • 使用Theo Pavlidis的算法追踪轮廓(连接性:4连通)
  • 顺时针方向 追踪 轮廓
  • 逆时针方向 追踪 孔洞

选项

 -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 to 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 hex notation RRGGBBAA (e.g. 112233FF)
 -a, --avcolor <AVCOLOR>   Avoid a given color in hex notation RRGGBBAA (e.g. 112233FF)
 -b, --bgcolor <BGCOLOR>   Add a background rectangle with a given color in hex notation RRGGBBAA (e.g. 112233FF)
 -i, --input <INPUT>       Input raster image filename (e.g. input.png)
 -o, --output <OUTPUT>     Output SVG filename (e.g. output.svg)

带有一些透明颜色的示例

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

(点击查看源代码)

800%缩放示例

(感谢Nayuki的QR码生成器)

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

  • qrcode_output.svg: qrcode_output.svg

(点击查看源代码)

信息

许可协议

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

版权所有 (c) 2022, STPR - https://github.com/STPR

SPDX-License-Identifier: EUPL-1.2

贡献

非常感谢您的贡献。请随时提出问题或发起拉取请求。请注意,任何提交给项目以包含的贡献将根据LICENSE.txt中给出的条款进行许可。

依赖项

约14MB
约67K SLoC