export async function convertIcoToPng(file) { // 1. 创建ICO的Blob URL const icoUrl = URL.createObjectURL(file) // 2. 加载到Image对象 const img = await new Promise((resolve, reject) => { const img = new Image() img.onload = () => resolve(img) img.onerror = reject img.src = icoUrl }) // 3. 绘制到Canvas const canvas = document.createElement('canvas') canvas.width = img.width canvas.height = img.height const ctx = canvas.getContext('2d') ctx.drawImage(img, 0, 0) // 4. 转换为PNG const pngDataUrl = canvas.toDataURL('image/png') URL.revokeObjectURL(icoUrl) // 释放内存 return { dataUrl: pngDataUrl, width: img.width, height: img.height } }