适用于Linux的SVG渲染器好吗? [英] Good SVG renderer for Linux?

查看:191
本文介绍了适用于Linux的SVG渲染器好吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一些脚本来生成SVG文件,并且我想知道对于Linux有什么好的SVG渲染器.我知道Firefox/Chrome提供了SVG支持(我觉得Chrome渲染速度更快),但也许我缺少其他独立的SVG渲染器.我知道pySVG的存在.

I'm developing some scripts to generate SVG files and I wonder what good SVG renderers exist for Linux. I know Firefox/Chrome provide SVG support (and I have the feeling that Chrome is faster at rendering) but maybe there are other standalone SVG renderers that I'm missing. I'm aware of pySVG's existence.

足够好,我的意思是尽可能覆盖SVG 1.1规范.我之所以选择独立的库,是因为我的工作流程更快,因为我不必每次都按F5键.

By good enough I mean to cover the SVG 1.1 specification as much as possible. The reason I prefer a standalone library is that my workflow is faster, as I don't have to press F5 every time.

推荐答案

draw.io工具导出的SVG 1.1太现代"了,无法被当前的Batik,Cairo,qiv甚至FireFox正确渲染:它们都不支持< foreignObject>元素.但是WebKit确实可以正确渲染它,因此要将SVG转换为高质量图像,我使用了 http:/上的"wkhtmlto ..."工具/wkhtmltopdf.org .

The SVG 1.1 exported by the draw.io tool is too "modern" for correct rendering by the current Batik, Cairo, qiv, or even FireFox: it seems none of them support the <foreignObject> element. However WebKit does render it properly, so to convert SVG to high-quality images I use the "wkhtmlto..." tools from http://wkhtmltopdf.org.

wkhtmltoimage会以屏幕分辨率生成输出,并且其--zoom开关按比例缩放线条和文本会导致裁剪(尽管在Chrome中打开了相同的SVG并正确执行了缩放).因此,我改为使用wkhtmltopdf生成一个中间pdf,然后使用ghostscript将其渲染为高分辨率图像:

wkhtmltoimage generates output at screen resolution and its --zoom switch scaled lines and text differently resulting in clipping (although opening the same SVG in Chrome and zooming performed correctly). So instead I'm using wkhtmltopdf to generate an intermediate pdf then rendering that as a high-resolution image with ghostscript:

wkhtmltopdf callbacks.svg callbacks.pdf
gs -sDEVICE=pnggray -sOutputFile=callbacks.png -dBATCH -dNOPAUSE -r900 callbacks.pdf

通过页面描述格式进行操作的一个缺点是生成的图像文件可能具有非常大的边框.您可以尝试使用纸张尺寸和布局以将其最小化,或者仅自动裁剪掉它们,例如使用ImageMagick:

a disadvantage of going via a Page Description Format is that the image file produced may have very large borders. You can experiment with paper sizes and layouts to minimise this or just auto-crop them off, e.g. with ImageMagick:

convert callbacks.png -trim callbacks.png

FireFox 49.0.2(2016年11月)现在可以正确渲染draw.io SVG.尚未重新测试开罗或蜡染. 示例draw.io文件

FireFox 49.0.2 (Nov 2016) now renders the draw.io SVG correctly. Haven't retested Cairo or Batik. sample draw.io file

这篇关于适用于Linux的SVG渲染器好吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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