Converting GIF's, PNG's and JPG's to .ICO files using Imagemagick

Chris Braid picture Chris Braid · Jul 6, 2010 · Viewed 37.8k times · Source

From: JPG, To: ICO;

/usr/bin/convert -resize x16 -gravity center -crop 16x16+0+0 input.jpg \
-transparent white -colors 256 output/favicon.ico 

This is the output for the command line.

From: GIF's, PNG To: ICO;

/usr/bin/convert -resize x16 -gravity center -crop 16x16+0+0 input.png \
-flatten -colors 256 output/favicon.ico 

I am having issues with transparency. I can't seem to get the right code for it, i have tried -channel alpha -negate, etc

This creates an image and when i apply to the site, it works with Firefox but none of the other browsers. IE, Chrome, Opera and Safari all hate it for some reason, it is a simple favicon.ico file. My conclusion is it must be my command somewhere is breaking. Please help?

Answer

jcoffland picture jcoffland · Nov 12, 2012

Add this option to convert:

-background transparent

However, keep in mind that your original image must actually have an alpha channel. PNGs may have an alpha channel, JPEGs do not.