创建多分辨率图标

Hen*_*gen 3 favicon

我正在寻找一种从单个图像创建favicon.ico的方法,但是,我遇到了所有分辨率的问题.

我已经在几个论坛帖子和网站上尝试了'convert -file1- -file2- favicon.ico',但这并不是我想要的.

Hen*_*gen 6

经过一番搜索,我想出了两个解决方案:

解决方案#1:

您可以登录任何安装了ImageMagick的linux框,将源图像(分辨率至少为256x256像素,PNG格式文件)重命名为'favicon.png',然后运行以下命令:

convert favicon.png -bordercolor white -border 0 \
      \( -clone 0 -resize 16x16 \) \
      \( -clone 0 -resize 32x32 \) \
      \( -clone 0 -resize 48x48 \) \
      \( -clone 0 -resize 57x57 \) \
      \( -clone 0 -resize 64x64 \) \
      \( -clone 0 -resize 72x72 \) \
      \( -clone 0 -resize 110x110 \) \
      \( -clone 0 -resize 114x114 \) \
      \( -clone 0 -resize 120x120 \) \
      \( -clone 0 -resize 128x128 \) \
      \( -clone 0 -resize 144x144 \) \
      \( -clone 0 -resize 152x152 \) \
      -delete 0 -alpha off -colors 256 favicon.ico
Run Code Online (Sandbox Code Playgroud)

..并且你将你的favicon.ico与大多数知名格式一起烘焙到一个文件中.

请务必查看favicon备忘单@ https://github.com/audreyr/favicon-cheat-sheet以获取更多favicon信息.

解决方案#2:

冒着推广最终会变成付费服务的网站的风险:

对于那些没有Imagemagick的人或者没有关于如何实现这些favicons的知识,请看一下我对http://realfavicongenerator.net的这个提示 ..它还会生成HTML代码并为您提供一些额外的选项为某些平台呈现文件.


Law*_*man 5

以下更简单的命令具有与 Henry 提到的相似的结果,但保留原始 PNG 文件中的任何透明度:

convert favicon.png -define icon:auto-resize=152,144,128,120,114,110,72,64,57,48,32,16 favicon.ico
Run Code Online (Sandbox Code Playgroud)

据推测,您可以通过在此命令中添加“-alpha off”来禁用透明度(如果需要)。