Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save Bicet/33ff29db1bf7600ad35e15c22d5be8c5 to your computer and use it in GitHub Desktop.

Select an option

Save Bicet/33ff29db1bf7600ad35e15c22d5be8c5 to your computer and use it in GitHub Desktop.
Convert Android VectorDrawable to png

转换方法:

  1. Convert Android VectorDrawable to SVG:

使用附件中的java程序。命令如下:

cp Vector2Svg.java path/to/xml_dir
javac Vector2Svg.java
java Vector2Svg ./*.xml
mkdir svg_dir
mv *.svg svg_dir

./*.xml为目标Android VectorDrawable的xml文件列表 然后程序会在对应目录生成同名的svg

  1. Convert SVG to PNG:

最简单的方法是直接使用Ubuntu的图片浏览器打开,然后另存为png

批量转换:

sudo apt-get install librsvg2-bin
cd svg_dir
for i in *; do rsvg-convert $i -o `echo $i | sed -e 's/svg$/png/'`; done

安装rsvg库,使用rsvg 转换svg到png.

附件中svg.tgz,是昨天图片的png结果。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment