Convert a png or jpeg to a favicon.ico with ImageMagick

ImageMagick is a sweet command line tool for doing a number of different things with images, but yet another cool discovery I found today is you can use it to convert an image to a favicon.ico file for your website. You can even do it using a URL or file.

First you need to install ImageMagick if you don’t already have it (see also dev-env-win):
winget install ImageMagick.ImageMagick

Then you simply run your command like this for a URL:
magick "https://site.net/images/avatar.jpg" -define icon:auto-resize=64,48,32,16 favicon.ico

Just replace the URL in the above example with a file path if you already have the file local.

Please remember to subscribe to the newsletter or feed to stay up to date.

Disclaimer: Thoughts and opinions are my own, and do not reflect the views of any employer, family member, friend, or anyone else. Some links may be affiliate links, but I do not link to anything I do not use myself.