waybetter-for-x/apps/desktop/scripts/generate-logo.mjs
2026-10-01 06:01:13 +07:00

15 lines
1.4 KiB
JavaScript

// Regenerates the source artwork for the app icon with OpenAI's image model.
// Usage: OPENAI_API_KEY=... node scripts/generate-logo.mjs out.png
// Then crop to the tile, apply the squircle mask and run `bunx tauri icon` (see HANDOFF).
import { writeFileSync } from 'node:fs';
const key = process.env.OPENAI_API_KEY?.trim();
if (!key) { console.error('Set OPENAI_API_KEY'); process.exit(1); }
const prompt = 'A premium modern desktop app icon, 1024x1024, a rounded-square (macOS squircle) tile centered with even transparent margin around it, nothing outside the tile. No text, no letters, no watermark. The classic Twitter bird facing right in white, its wing drawn as a single sweeping paint-brush stroke that fades from white to cyan to violet, suggesting themes and customization. Tile is a rich deep indigo-to-blue gradient with a faint noise texture. A small four-point sparkle near the wingtip. Modern, bold, minimal, Dribbble-quality.';
const res = await fetch('https://api.openai.com/v1/images/generations', {
method: 'POST',
headers: { Authorization: `Bearer ${key}`, 'Content-Type': 'application/json' },
body: JSON.stringify({ model: 'gpt-image-2.5-sunburst', prompt, size: '1024x1024', quality: 'high', background: 'transparent' }),
});
const json = await res.json();
if (!res.ok) { console.error(json.error ?? json); process.exit(1); }
writeFileSync(process.argv[2] ?? 'logo.png', Buffer.from(json.data[0].b64_json, 'base64'));