使用终端将 .JPG 或 .PNG 转换为 .ICO 并返回

Eli*_*ces 35 command-line convert

是否有一个命令,我可以使用一个转换.jpg.png或其他分机的.ico?如果可能的话,还要将其调整为网站图标大小?

我也想把它从.ico.jpgor .png

小智 54

处理图像最有用的程序(套件)是Imagemagick ( sudo apt install imagemagick) 并且对于此任务,您将需要convert二进制文件。

您将需要使用以下内容:

convert -resize x16 -gravity center -crop 16x16+0+0 input.png -flatten -colors 256 -background transparent output/favicon.ico
Run Code Online (Sandbox Code Playgroud)

  • 透明度的去除很可能是由于使用了“-flatten”标志。 (3认同)

小智 29

这是从控制台执行此操作的最佳命令:

convert <your-image-here> -define icon:auto-resize=256,64,48,32,16 favicon.ico

希望你喜欢!

  • `icon:auto-resize` 自动在 ico 图像中存储多种尺寸(*需要 256x256 输入图像*)。 (3认同)