Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multifile favicon.ico much bigger than sum of sizes of component files

I want to create multifile favicon.ico according to great favicon cheat sheet.
I created 3 .png files, optimized them with OptiPNG and received files with 1, 2 and 3kb size.
Now I'm trying to create favicon.ico from them using Imagemagick but final file is around 15kb big (sum of component files is around 6kB).
What causes this effect and how i can avoid it ?

like image 315
Banciur Avatar asked Oct 20 '22 12:10

Banciur


2 Answers

A workaround is to rely on the HTTP gzip compression.

For example, I packed 3 PNG pictures (3580 bytes in total) in a 15086 bytes favicon.ico file. When I download it with gzip compression enabled on the server side, I get 2551 bytes of data. This is even more efficient than downloading the PNG pictures one by one, as gzip is usually not enabled for this kind of file.

However, gzip is often not configured for .ico files (this is more for text files). On Apache, this can be fixed by adding:

<IfModule mod_deflate.c>
    (... other rules here...)
    AddOutputFilterByType DEFLATE image/x-icon
</IfModule>

in an Apache configuration file, such as /etc/apache2/mods-available/deflate.conf.

This is not the answer you expected and I hope someone will come with a magic command line to produce the lightweight favicon.ico we deserve!

like image 195
philippe_b Avatar answered Oct 23 '22 22:10

philippe_b


Another workaround is using other another tool to create favicon file.
I found (on stack ofc ;)) png2ico tool. It gave me 8kb file (sum of components is around 6) which is size I can live with.

Please read comments to this answer - philippe_b observed that sometimes png2ico gives him poor results.

like image 24
Banciur Avatar answered Oct 24 '22 00:10

Banciur