Good SVG renderer for Linux? [closed]

2019-02-06 14:54发布

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.

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.

标签: linux svg
5条回答
何必那么认真
2楼-- · 2019-02-06 15:12

Qt SVG it's just 2 clicks away, if you install Qt 4.7 and select the locally installed sample project svgviewer. Just build and run to get an animated viewport:

enter image description here

查看更多
乱世女痞
3楼-- · 2019-02-06 15:15

Apache Batik is a very good collection of libraries/programs with support for a very large part of the SVG specification. It includes a stand-alone viewer/editor, and a command line rasterizer that can convert SVGs to raster image formats.

查看更多
来,给爷笑一个
4楼-- · 2019-02-06 15:15

You can try the command-line app qiv with the -m -T flags.

查看更多
小情绪 Triste *
5楼-- · 2019-02-06 15:23

I recommend WebkitGtk. This is the renderer that is used to power Safari, Chrome, and a number of other browsers. It supports rendering SVG as well as HTML.

Just apt-get install libwebkitgt-3.0-0. You can try it out by running /usr/lib/webkitgtk-3.0-0/libexec/GtkLauncher.

You can then use whatever language/bindings you like to build a GUI around the SVG renderer, including Python's Gtk bindings: http://www.aclevername.com/articles/python-webgui/

Here's another good article about building desktop UIs using Webkit and pygtk bindings: http://arstechnica.com/information-technology/2009/07/how-to-build-a-desktop-wysiwyg-editor-with-webkit-and-html-5/

查看更多
萌系小妹纸
6楼-- · 2019-02-06 15:31

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 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

EDIT: 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

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

查看更多
登录 后发表回答