
ImageMagick: How to Create a Favicon
Updated
Learn how to create a favicon.ico from a PNG using ImageMagick
Before we start, make sure you have ImageMagick installed on your computer and a square PNG logo ready in a folder. A size of at least 256x256 works best. If you don't have ImageMagick yet, run this command:
brew install imagemagick
First, open your terminal and navigate to the folder that has your logo. To create the favicon, run this command:
magick input.png -define icon:auto-resize=16,32,48,64,256 favicon.ico
Just remember to replace input.png with your actual filename. The -define icon:auto-resize option packs several sizes into one favicon.ico file, and the numbers 16,32,48,64,256 are the sizes in pixels. You can add as many sizes as you like. Don't worry if you don't see a success message, the command finishes in a flash.
To make sure everything worked, check what's inside the file:
magick identify favicon.ico
You should see one line for each size, from 16x16 up to 256x256. Then move favicon.ico into the root folder of your website and add this line inside your head tag:
One more tip: phones also look for a PNG icon. To create one, run magick input.png -resize 180x180 apple-touch-icon.png.
