Skip to content

Instantly share code, notes, and snippets.

@azam
Last active September 11, 2024 20:05
Show Gist options
  • Save azam/3b6995a29b9f079282f3 to your computer and use it in GitHub Desktop.
Save azam/3b6995a29b9f079282f3 to your computer and use it in GitHub Desktop.
Convert SVG to ICO using ImageMagick, with transparent background and multi-size icons
convert -density 256x256 -background transparent favicon.svg -define icon:auto-resize -colors 256 favicon.ico
@mjhasbach
Copy link

The icon can also be colored:

convert -density 384 -background transparent -fill "#607D8B" -colorize 100 favicon.svg -define icon:auto-resize -colors 256 favicon.ico

@ki9us
Copy link

ki9us commented May 8, 2016

For anyone else wondering why the density must be set

@graingert
Copy link

@mjhasbach @azam @keith24 I'm still getting blurry images with this. Is there an icon:auto-density ?

@drmercer
Copy link

@graingert I got better results by using -density 256x256 as specified in this SO answer.

@wieczorek1990
Copy link

So to sumarize, use:

convert -density 256x256 -background transparent favicon.svg -define icon:auto-resize -colors 256 favicon.ico

@char1es31
Copy link

This can be done in magick directly:

magick -density 256x256 -background transparent favicon.svg -define icon:auto-resize -colors 256 favicon.ico

@azam
Copy link
Author

azam commented Jan 16, 2020

Updated with latest working parameters. Thanks all !

@jmgeffroy
Copy link

Hi there, I'm jumping into this thread long after the previous post... But this command gives me a multi-sized ICO as expected, but all dimensions are completely white (or any color I specify as the background parameter)... I don't find any clue about it for now...

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