How to convert a SVG to a PNG with ImageMagick?

前端 未结 18 2031
一个人的身影
一个人的身影 2020-11-28 17:04

I have a SVG file that has a defined size of 16x16. When I use ImageMagick\'s convert program to convert it into a PNG, then I get a 16x16 pixel PNG which is way too small:<

18条回答
  •  醉梦人生
    2020-11-28 17:47

    This is what worked for me

    find . -type f -name "*.svg" -exec bash -c 'rsvg-convert -h 1000  $0 > $0.png' {} \;
    rename 's/svg\.png/png/' *
    

    This will loop all the files in your current folder and sub folder and look for .svg files and will convert it to png with transparent background.

    Make sure you have installed the librsvg and rename util

    brew install librsvg
    brew install rename
    

提交回复
热议问题