Render an SVG with filter effects to PNG

夙愿已清 提交于 2019-12-23 12:44:52

问题


I would like to render an SVG I've created to a hi-res (600 DPI) PNG. This SVG has filter effects, specifically gaussian blur.

Ideally rendering could be done via the command line.

I know the SVG is renderable because you can open it in Chrome/Chromium and the output I'd like to see is there.

Things I've tried:

Importing to Adobe Illustrator

svg2png

Imagemagick

Inkscape

Other command-line tools and programs I'm forgetting right now. Basically anything you could find with Google.

Current path I'm pursuing but stuck on:

Knowing that Chromium can render the SVG just fine and that it's open-source, I figured I'd download the library Chromium depends on to render SVGs (Skia, https://sites.google.com/site/skiadocs/) and use it to output a PNG. So far I've succeeded in installing Skia and running the very first example. I've found an example that renders an SVG (https://code.google.com/p/skia/source/browse/trunk/samplecode/SampleSVG.cpp?r=875) but haven't successfully run it on my OSX machine with the latest updates to XCode and command-line tools. A modified version of that example (with gyp file) that outputs a PNG would be amazing.

Other ideas that might work:

Getting pixel data from Chrome (how would I do that? A simple screenshot isn't enough because of the resolution of the image. I also want a scriptable, repeatable process.)

Using other graphics library that can render SVG. Maybe this comes from other web browsers, maybe not.


回答1:


This seems to work nicely:

webkit2png -F blue.svg -o rendered

The -F says to generate the Full resolution PNG and no thumbnails, and the -o specified that the output filename will be rendered-full.png.

I have reduced the size so it fits on Stack Overflow, but the command shown actually gives the full-resolution 2880x2880 image.



来源:https://stackoverflow.com/questions/28444841/render-an-svg-with-filter-effects-to-png

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!