Why is my favicon.ico file so much larger than the sum of its parts?
Asked Answered
E

1

10

I have created a favicon.ico file that contains three sizes of .png icon sizes, 16px, 32px, and 64px.

In my Mac Finder, I have their sizes at 339b, 1kb, and 4kb respectively after optimizing them using ImageOptim. So let's maybe round up to 6kb?

However, when I run this ImageMagick command:

convert 16.png 32.png 64.png myfav.ico

The resulting .ico file is 22kb!

This is a pretty large file and unexpected.

What did I do wrong? What can I do to make it smaller (if anything)?

Elmaelmajian answered 14/7, 2015 at 0:11 Comment(0)
C
14

The ico file itself is not a compressed one.

You can gzip it and you will see that the gzipped size will be lesser than the summation of the sizes the 3 png files. ico files are most frequently gzipped (using apache, nginx and so on) before being used to reduce the size.

So, the reason they are so big is because the compression algorithm is weak.

Crossbar answered 14/7, 2015 at 0:30 Comment(2)
Thanks for your answer, I guess I thought that .ico was just a container to holding the file(s), I didn't think it was like a whole other image format... which I'm guessing now maybe it is?Elmaelmajian
Usually, the images in an .ico are held as uncompressed BMP images. If you're converting from png, these will probably be stored at 32bits per pixel. When Windows Vista came along, Microsoft added support for embedded PNG files, but this tends to be for 256x256 icons so that older apps don't break.Public

© 2022 - 2024 — McMap. All rights reserved.