所以我想要一个从 jpg/png 生成
.ico
文件的工具。
我使用以下代码从画布生成了 jpg:
var img = c.toDataURL("image/png");
document.write('<img src="'+img+'"/>');
取自此画布:
<canvas id="myCanvas" width="16" height="16">
所以问题是;是否可以将生成的png转换为ico?
在 Firefox 中,您可以直接从画布执行此操作:
// Make ICO files (Firefox only)
var ctx = c.getContext("2d");
ctx.arc(c.width>>1, c.height>>1, c.width>>1, 0, 6.28);
ctx.fill();
c.toBlob(function(blob) {
console.log(blob)
}, 'image/vnd.microsoft.icon', '-moz-parse-options:format=bmp;bpp=32');
<canvas id=c width=32 height=32></canvas>
从 ICO 文件中提取图像:ICO 文件可以包含多个不同大小和颜色深度的图像。转换过程通常从从 ICO 文件中提取图像开始。您可以访问此网站https://thistothat.online/jpg-to-ico.