// Deterministic 1200x630 link preview from the app icon and synthetic UI captures.
import { readFile } from 'node:fs/promises';
import sharp from 'sharp';
const root = new URL('../', import.meta.url);
const background = Buffer.from(``);
async function phone(name, width, height) {
const shot = await sharp(new URL(`src/assets/screenshots/${name}.png`, root).pathname)
.resize({ width }).extract({ left: 0, top: 0, width, height }).png().toBuffer();
const mask = Buffer.from(``);
return sharp(shot).composite([{ input: mask, blend: 'dest-in' }]).png().toBuffer();
}
await sharp(background).composite([
{ input: await sharp(await readFile(new URL('public/logo.svg', root))).resize(112).png().toBuffer(), left: 62, top: 82 },
{ input: await phone('backup', 220, 450), left: 638, top: 120 },
{ input: await phone('photos', 260, 528), left: 870, top: 50 },
]).png({ compressionLevel: 9 }).toFile(new URL('public/og.png', root).pathname);
console.log('wrote public/og.png');