简体   繁体   English

通过画布从svg或svg输出300个具有正确文件名的png图像?

[英]Output 300 png images with correct filenames from svg or svg via canvas?

For browsers that don't support SVG, I'd like to show a static image of a chart instead of an interactive version. 对于不支持SVG的浏览器,我想显示图表的静态图像,而不是交互式版本。

One idea is to generate all possible chart states (around 300) beforehand. 一种想法是事先生成所有可能的图表状态(大约300个)。 I tried using the Canvas2Image library but it doesn't seem to allow me to specify a filename. 我尝试使用Canvas2Image库,但是它似乎不允许我指定文件名。 Is there any workaround? 有什么解决方法吗? Perhaps a server-side solution? 也许是服务器端的解决方案?

There's a couple other ways to solve this. 还有其他几种方法可以解决此问题。

rsvg is a rendering library that processes SVGs statically single-pass. rsvg是一个渲染库,可静态单遍处理rsvg It's used in ImageMagick's convert tool, and also has python and other bindings. 它用于ImageMagick的转换工具,还具有python和其他绑定。 Some people find various SVG-isms aren't supported, but rsvg gets updates now and then so best to just try and see. 某些人发现不支持各种SVG-ism,但是rsvg有时会获取更新,因此最好尝试一下。

inkscape is a GUI program that includes SVG->PNG conversion. inkscape是一个GUI程序,其中包括SVG-> PNG转换。 But it can also be used exclusively on the command line (no X11 required). 但是它也可以仅在命令行上使用(不需要X11)。 See man inkscape for all the command line options that can be used to process your svg's; 有关可用于处理svg的所有命令行选项,请参见man inkscape it's quite flexible. 它非常灵活。 The rendering is relatively fast. 渲染相对较快。 The main downside is that being a GUI program it has a lot of dependencies, that might not be present on a web server. 主要缺点是,作为GUI程序,它具有很多依赖关系,而这些依赖关系可能在Web服务器上不存在。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM