使用PhantomJS的SVG到PNG转换器
您有一个SVG文件。 无论出于何种原因,您都需要PNG。 svg2png可以提供帮助。
const fs = require ( "pn/fs" ) ; // https://www.npmjs.com/package/pn
const svg2png = require ( "svg2png" ) ;
fs . readFile ( "source.svg" )
. then ( svg2png )
. then ( buffer => fs . writeFile ( "dest.png" , buffer ) )
. catch ( e => console . error ( e ) ) ;
在上面的示例中,我们使用SVG文件中指定的width和height属性来自动确定SVG的大小。 您还可以显式设置大小
评论0
最新资源