It looks like ImageMagick does not always convert a single favicon.ico file to a predictable single png file - for some favicon's, it generates a bunch of other favicon-01.png, favicon-02.png, etc... Is there a way to figure out which one's the actual converted favicon you want - or figure out how many got generated, to delete the unwanted ones?
3 Answers
I came across with the same problem while I was trying to convert blogger's favicon and I solved it by using -flatten parameter of Imagemagick like this:
convert "favicon.ico" -thumbnail 16x16 -alpha on -background none -flatten "favicon.png"

- 2,690
- 22
- 20
-
1Flawless, and it retains the transparent background too. Thanks! – Ferdinand Prantl Dec 26 '13 at 14:49
-
Also, you can check my web service http://geticon.org/ and it's source: https://github.com/gokercebeci/geticon – goker Feb 10 '14 at 08:06
-
Again, the Swiss Army knife in the world of image processing saved me from massive head-ache. – Andreas Oct 20 '20 at 09:18
This likely happens because there are multiple images in the icon file - this is to provide differet resolutions for different contexts. Presumably you'd want to run a search in the target directory for favicon*.png
, then check the dimensions of each one to find the one you wanted (deleting the others as you go).

- 320,036
- 81
- 464
- 592
I guess some of these are animated gifs. You can take the first one as described here:
i.e.:
$magick> convert 'images.gif[0]' image.png
I don't have ImageMagic installed, but you might try the above for all favicon.ico, it might work fine.
Otherwise, you would probably need to write a script to check for favicon-01.png and, if it exists, rename it to favicon.png and delete favicon-*.png (provided you don't have anything else named like that in the working folder).

- 27,952
- 4
- 66
- 85