使用Python将BMP/PNG/JPEG转换为SVG文件 [英] Converting a BMP/PNG/JPEG to an SVG file using Python

查看:214
本文介绍了使用Python将BMP/PNG/JPEG转换为SVG文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试使用Python将BMP文件转换为SVG文件.我正在尝试找到一个Python库,该库可使我将BMP/PNG/JPEG文件转换为SVG文件.

I'm currently trying to convert BMP files to SVG files using Python. I'm trying to find a Python library that will enable me to convert BMP/PNG/JPEG files to SVG files.

我已经尝试过使用Potrace,但是质量太差了.我需要最终结果是相当高质量的.我无法使用在线转换器,并且在处理敏感数据时必须能够在计算机上进行这些转换.

I've already tried using Potrace but the quality is awful. I need the end results to be fairly high-quality. I can't use online converters and must be able to do these conversions on my machine as I'm working with sensitive data.

任何建议将不胜感激.谢谢!

Any suggestions would be greatly appreciated. Thank you!

我发现我在测试中没有使用正确的Potrace设置.这就是产生糟糕"结果的原因.不幸的是,我还了解到Potrace不支持颜色输出.我已经把Inkscape和Vector Magic弄混了,我认为它们是目前最好的选择.

I found out that I wasn't using the correct settings for Potrace in my testing. This is what yielded the "awful" result. Unfortunately, I've also learned that Potrace doesn't support color outputs. I've messed around with Inkscape and Vector Magic and I think they're my best bet at the moment.

推荐答案

我建议对Python使用Potrace.
使用此链接: https://pypi.org/project/pypotrace/
这里是文档: https://pythonhosted.org/pypotrace/ref.html#

像这样:

I would suggest using potrace for python.
Use this link: https://pypi.org/project/pypotrace/
Here is the documentation: https://pythonhosted.org/pypotrace/ref.html#

Like This:

from potrace import Bitmap

# Initialize data, for example convert a PIL image to a numpy array
# [...]

bitmap = Bitmap(data)
path = bitmap.trace()

这篇关于使用Python将BMP/PNG/JPEG转换为SVG文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆