// Derives a transparent wordmark from `Full Logo.png`. // // The source file has an opaque pure-black (#000000) plate, which shows up as // a visible rectangle on the site background (#0a0a0a). The logo is two-tone // (cream on black), so its luminance can be reused directly as an alpha mask. // // Run with: node scripts/build-wordmark.mjs import sharp from "sharp"; import { resolve } from "node:path"; const ROOT = resolve(import.meta.dirname, ".."); const SOURCE = resolve(ROOT, "public/image/Studio/Full Logo.png"); const OUT = resolve(ROOT, "public/image/Studio/Wordmark.png"); const INK = { r: 232, g: 223, b: 204 }; // --foreground const { width, height } = await sharp(SOURCE).metadata(); // Luminance of the source becomes the alpha channel. const alpha = await sharp(SOURCE).greyscale().raw().toBuffer(); const tinted = await sharp({ create: { width, height, channels: 3, background: INK }, }) .joinChannel(alpha, { raw: { width, height, channels: 1 } }) .png() .toBuffer(); // Drop the empty margins so the asset can be sized predictably. const trimmed = await sharp(tinted) .trim({ threshold: 2 }) .png({ compressionLevel: 9 }) .toBuffer(); const meta = await sharp(trimmed).metadata(); await sharp(trimmed).toFile(OUT); console.log(`Wordmark.png: ${meta.width}x${meta.height}, ${trimmed.length} bytes`);