macOS下如何将.svg格式的图片转为.png、.jpg等常用格式呢?
方案很多,这里介绍librsvg。
安装librsvg
brew install librsvg
完成后查看版本:
rsvg-convert --version
svg转png
一行命令搞定:
// 命令格式
rsvg-convert >
// 举个栗子(有很多参数可配置)
rsvg-convert -d 90 -p 90 -w 360 -h 360 jklogo.svg > jklogo.png
librsvg帮助
ypfdeMBP15:临时图片 ypf$ rsvg-convert --help
用法:
rsvg-convert [选项…] [FILE...] - SVG Converter
帮助选项:
-?, --help 显示帮助选项
应用程序选项:
-d, --dpi-x= pixels per inch [optional; defaults to 90dpi]
-p, --dpi-y= pixels per inch [optional; defaults to 90dpi]
-x, --x-zoom= x zoom factor [optional; defaults to 1.0]
-y, --y-zoom= y zoom factor [optional; defaults to 1.0]
-z, --zoom= zoom factor [optional; defaults to 1.0]
-w, --width= width [optional; defaults to the SVG's width]
-h, --height= height [optional; defaults to the SVG's height]
-f, --format=[png, pdf, ps, eps, svg, xml, recording] save format [optional; defaults to 'png']
-o, --output output filename [optional; defaults to stdout]
-i, --export-id= SVG id of object to export [optional; defaults to exporting all objects]
-a, --keep-aspect-ratio whether to preserve the aspect ratio [optional; defaults to FALSE]
-b, --background-color=[black, white, #abccee, #aaa...] set the background color [optional; defaults to None]
-s, --stylesheet Filename of CSS stylesheet
-u, --unlimited Allow huge SVG files
--keep-image-data Keep image data
--no-keep-image-data Don't keep image data
-v, --version show version information
ypfdeMBP15:临时图片 ypf$