[lhdop@blog img]$ /usr/bin/convert -resize x128 fl.png -background transparent a3.ico查看生成的ico
[lhdop@blog img]$ identify a3.ico a3.ico ICO 84x128 84x128+0+0 8-bit sRGB 44606B 0.000u 0:00.000可见生成的ico不是标准的正方形
说明:刘宏缔的架构森林是一个专注架构的博客,地址:https://www.cnblogs.com/architectforest
对应的源码可以访问这里获取: https://github.com/liuhongdi/
或: https://gitee.com/liuhongdi
说明:作者:刘宏缔 邮箱: 371125307@qq.com
[lhdop@blog img]$ /usr/bin/convert -resize 128x -gravity center -crop 128x128+0+0 fl.png -background transparent a4.ico原图: fl.png 截取中间正方形后: a4.ico 查看生成的ico
[lhdop@blog img]$ identify a4.ico a4.ico ICO 128x128 128x128+0+0 8-bit sRGB 67646B 0.000u 0:00.000
[lhdop@blog img]$ /usr/bin/convert -resize 128x128! fl.png -background transparent a5.ico如图: 查看生成的ico:
[lhdop@blog img]$ identify a5.ico a5.ico ICO 128x128 128x128+0+0 8-bit sRGB 67646B 0.000u 0:00.000
[lhdop@blog img]$ convert -background transparent fl.png -define icon:auto-resize=16,24,32,48,64,72,96,128,256 a6.ico查看生成的ico:
[lhdop@blog img]$ identify a6.ico a6.ico[0] ICO 16x16 16x16+0+0 8-bit sRGB 0.000u 0:00.002 a6.ico[1] ICO 24x24 24x24+0+0 8-bit sRGB 0.000u 0:00.002 a6.ico[2] ICO 32x32 32x32+0+0 8-bit sRGB 0.000u 0:00.002 a6.ico[3] ICO 48x48 48x48+0+0 8-bit sRGB 0.000u 0:00.002 a6.ico[4] ICO 64x64 64x64+0+0 8-bit sRGB 0.000u 0:00.002 a6.ico[5] ICO 72x72 72x72+0+0 8-bit sRGB 0.000u 0:00.002 a6.ico[6] ICO 96x96 96x96+0+0 8-bit sRGB 0.000u 0:00.001 a6.ico[7] ICO 128x128 128x128+0+0 8-bit sRGB 0.000u 0:00.001 a6.ico[8] PNG 256x256 256x256+0+0 8-bit sRGB 197772B 0.000u 0:00.000可以看到共有我们指定的9个size
[lhdop@blog img]$ convert --version Version: ImageMagick 6.9.10-86 Q16 x86_64 2020-01-13 https://imagemagick.org Copyright: © 1999-2020 ImageMagick Studio LLC License: https://imagemagick.org/script/license.php Features: Cipher DPC Modules OpenMP(4.5) Delegates (built-in): bzlib cairo fftw fontconfig freetype gslib gvc jbig jng jp2 jpeg lcms ltdl lzma openexr pangocairo png ps raqm raw rsvg tiff webp wmf x xml zlib