/** * Builds app-icon.png (1024) and public/logo.png (512) from the supplied * 2048x2048 transparent PNG. Run: npm run icon:make */ import fs from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; import sharp from "sharp"; const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."); const SOURCE = path.join(ROOT, "assets", "branding", "ld-fdpi-logo-source.png"); const APP_ICON = path.join(ROOT, "app-icon.png"); const PUBLIC_LOGO = path.join(ROOT, "public", "logo.png"); if (!fs.existsSync(SOURCE)) { console.error("assets/branding/ld-fdpi-logo-source.png bulunamadı."); process.exit(1); } // The source already has transparent corners; trim the transparent margin so // the mark fills the taskbar/installer icon instead of looking tiny. const base = sharp(SOURCE) .ensureAlpha() .trim({ background: { r: 0, g: 0, b: 0, alpha: 0 }, threshold: 10 }); await base .clone() .resize(1024, 1024, { fit: "contain", background: { r: 0, g: 0, b: 0, alpha: 0 }, }) .png({ compressionLevel: 9, adaptiveFiltering: true }) .toFile(APP_ICON); await base .clone() .resize(512, 512, { fit: "contain", background: { r: 0, g: 0, b: 0, alpha: 0 }, }) .png({ compressionLevel: 9, adaptiveFiltering: true }) .toFile(PUBLIC_LOGO); const meta = await sharp(APP_ICON).metadata(); console.log( `[LD FDPI] app-icon.png ${meta.width}x${meta.height}; public/logo.png 512x512` );