const sharp = require('sharp'); const fs = require('fs'); const path = require('path'); const svgPath = path.join(__dirname, '..', 'public', 'favicon.svg'); const svg = fs.readFileSync(svgPath); async function generate() { await sharp(svg).resize(180, 180).png().toFile(path.join(__dirname, '..', 'public', 'apple-touch-icon.png')); console.log('apple-touch-icon.png (180x180) generated'); await sharp(svg).resize(32, 32).png().toFile(path.join(__dirname, '..', 'public', 'favicon-32x32.png')); console.log('favicon-32x32.png generated'); await sharp(svg).resize(16, 16).png().toFile(path.join(__dirname, '..', 'public', 'favicon-16x16.png')); console.log('favicon-16x16.png generated'); const png32 = await sharp(svg).resize(32, 32).png().toBuffer(); const header = Buffer.alloc(6); header.writeUInt16LE(0, 0); header.writeUInt16LE(1, 2); header.writeUInt16LE(1, 4); const entry = Buffer.alloc(16); entry.writeUInt8(32, 0); entry.writeUInt8(32, 1); entry.writeUInt8(0, 2); entry.writeUInt8(0, 3); entry.writeUInt16LE(1, 4); entry.writeUInt16LE(32, 6); entry.writeUInt32LE(png32.length, 8); entry.writeUInt32LE(22, 12); const ico = Buffer.concat([header, entry, png32]); fs.writeFileSync(path.join(__dirname, '..', 'public', 'favicon.ico'), ico); console.log('favicon.ico generated'); console.log('All favicon files generated!'); } generate().catch(err => console.error(err));