Skip to content

How to convert SVG to PNG on a MAC?

This simple command will allow you to generate a PNG of a Font Awesome SVG icon, in the color that you want.

 

sed -i '' 's/path /path fill="#2E74B5" /' fontawesome.svg ; qlmanage -t -s 24 -o . fontawesome.svg

Command Breakdown:

gnu-sed is used, instead of OSX sed shipped with the mac.

brew install gnu-sed --with-default-names
sed -i '' 's/path /path fill="#2E74B5" /' fontawesome.svg ;

Add an RGB color fill to the fontawesome svg icon file

  • -i ” — sed edit in place
  • “#2E74B5” — This should be your target fontawesome icon color
qlmanage -t -s 24 -o . fontawesome.svg

This command generates a thumbnail from the fontawesome icon file, named fontawesome.svg.png. The width of the png will be 24 pixels as specified in the command -s 24

 

And to convert the whole directory: use:

for x in `ls *.svg`;do sed -i 's/path /path fill="#2196F3" /' $x ; qlmanage -t -s 24
-o . $x; done

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: