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

孤街浪徒 提交于 2019-12-30 10:00:10

问题


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 ?


回答1:


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!




回答2:


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.




回答3:


Only the 256x256 32bit icon is PNG compressed, others are stored as classic icons in .ICO file. So, there's a logical increase in filesize since it will decompress the other smaller size icons.



来源:https://stackoverflow.com/questions/22561648/multifile-favicon-ico-much-bigger-than-sum-of-sizes-of-component-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!