如何获得imagemagick创建少于15k的图标 [英] How to get imagemagick to create a favicon less than 15k

查看:91
本文介绍了如何获得imagemagick创建少于15k的图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ImageMagick的 convert 命令将3个不同大小的图标(16、32、48像素正方形,正楷)组合到单个 favicon.ico 中.

I'm using ImageMagick's convert command to combine 3 different sized icons (16, 32, 48 pixels square, repsective) into a single favicon.ico.

$ convert --version
Version: ImageMagick 6.8.9-7 Q16 x86_64 2015-07-06 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC OpenMP
Delegates: bzlib freetype jng jpeg png tiff xml zlib

$ convert 16.png 32.png 48.png favicon.ico

这三个文件很小,因为我已经通过ImageAlpha和ImageOptim运行它们:

The three files are tiny, as I've already run them through ImageAlpha and ImageOptim:

$ ls -alh *.png 
-rw-r--r--   1 user  staff   219B Mar 20 11:46 16.png
-rw-r--r--   1 user  staff   344B Mar 20 11:46 32.png
-rw-r--r--   1 user  staff   469B Mar 20 11:44 48.png

但是ImageMagick创建的输出文件为15K

However the output file created by ImageMagick is 15K

$ ls -alh favicon.ico 
-rw-r--r--  1 user  staff    15K Mar 20 12:01 favicon.ico

类似地,当我将3张png图像提供给免费在线服务时,位于 icoconvert.com 上,生成的 output.ico 文件也为15K.

Similarly, when I provide my 3 png images to the the free online service at icoconvert.com, the output.ico file generated is also 15K.

为什么生成的文件如此之大,为什么还有另一种方法来获得较小的生成的ico文件?

推荐答案

这个大的意外大小是由于ICO格式本身而不是ImageMagick引起的.例如, icoutils 会给出类似的结果.警告: png2ico是报告会生成较小的文件,但这仅仅是因为它不保留原始图片.

This large, unexpected size is due to the ICO format itself, not ImageMagick. For example, icoutils gives similar results. Warning: png2ico is reported to produce smaller files but this is only because it doesn't preserve the original pictures.

一个有效的解决方法不是专注于 favicon.ico 文件本身,而是

Instead of focusing on the favicon.ico file itself, an effective workaround is to enable its compression at the HTTP level (eg. change Apache config to enable the GZip compression of .ico files).

这篇关于如何获得imagemagick创建少于15k的图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆