Convert favicon.ico to png for using ImageMagick Procedurally

It seems that ImageMagick does not always convert a single favicon.ico file into a predictable single png file - for some icons it generates a bunch of other favicon-01.png, favicon-02.png, etc. Is there any way to find out exactly which converted icon you want - or find out how many of them were created, delete unnecessary ones?

+7
favicon imagemagick image-conversion
source share
3 answers

I ran into the same problem while I was trying to convert a fage blogger, and I solved it using the -flatten Imagemagick parameter as follows:

convert "favicon.ico" -thumbnail 16x16 -alpha on -background none -flatten "favicon.png" 

alt text

+12
source share

This is probably due to the fact that there are several images in the icon file - this means that different permissions are provided for different contexts. Presumably, you want to run a search in the target directory for favicon*.png , and then check the sizes of each of them to find the one you need (delete the rest along the way).

+3
source share

I think some of them are animated gifs. You can take the first one as described here:

i.e:.

 $magick> convert 'images.gif[0]' image.png 

I do not have ImageMagic installed, but you can try the above for all favicon.ico, it can work fine.

Otherwise, you probably need to write a script to check favicon-01.png, and if it exists, rename it to favicon.png and delete favicon - *. png (if you have nothing else named so in the working folder).

+1
source share

All Articles