用于在Ruby或Python中解析SVG的库 [英] Library to parse SVG in Ruby or Python

查看:111
本文介绍了用于在Ruby或Python中解析SVG的库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SVG是一个巨大的标准,它基于XML.过去,我已将SVG解析为XML.但是,有些事情很难.

SVG is a huge standard, which is based on XML. I have parsed SVG as XML in the past. However, some things are hard.

例如,我想知道一个小组的规模.据我所知,这只能通过递归地遍历组中的所有子级(注意他们的所有变换)并累积其大小来实现.

For example, I would like to know the size of a group. As far as I can tell, this is only possible by recursively stepping through all the children in the group (noting all their transformations) and accumulating their sizes.

我很想拥有一个可以为我做类似事情的图书馆.是否存在这样的东西?

I would love to have a library that could do stuff like that for me. Does something like this exist?

推荐答案

在python中,您有 pysvg :

In python you have pysvg:

import pysvg.parser

svg = pysvg.parser.parse(<filename>)
print svg.get_width(), svg.get_height()

这篇关于用于在Ruby或Python中解析SVG的库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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