#!/usr/bin/env node // One-off: re-render after-juno-lineart.png as an upright portrait, // not the curled overhead pose of the source photo. The standard LINEART // prompt's "reinterpret as upright" hint isn't strong enough when the // reference is a tightly-curled overhead candid; this script bolts on // explicit anti-overhead language and routes through Gemini, which // follows pose-override instructions more literally than gpt-image-2. import fs from 'node:fs'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const ROOT = path.resolve(__dirname, '..'); function loadEnvLocal() { const p = path.join(ROOT, '.env.local'); if (!fs.existsSync(p)) return; for (const raw of fs.readFileSync(p, 'utf8').split('\n')) { const line = raw.trim(); if (!line || line.startsWith('#')) continue; const eq = line.indexOf('='); if (eq < 0) continue; const key = line.slice(0, eq).trim(); let val = line.slice(eq + 1).trim(); if ((val.startsWith('"') && val.endsWith('"')) || (val.startsWith("'") && val.endsWith("'"))) { val = val.slice(1, -1); } if (!(key in process.env)) process.env[key] = val; } } loadEnvLocal(); const GEMINI_KEY = process.env.GEMINI_API_KEY; if (!GEMINI_KEY) { console.error('GEMINI_API_KEY not set'); process.exit(1); } const REFERENCE = path.resolve(ROOT, 'public/portraits/before-juno.jpg'); const OUT_PATH = path.resolve(ROOT, 'public/portraits/after-juno-lineart.png'); const refBytes = fs.readFileSync(REFERENCE); const refB64 = refBytes.toString('base64'); const PROMPT = `Create a refined, richly detailed black line-drawing portrait of the dog shown in the reference photo — the look of a polished editorial pen-and-ink illustration. POSE OVERRIDE — CRITICAL: - The reference photo shows the dog curled up on a sofa, photographed from a high overhead angle. IGNORE this candid pose entirely. - Render the dog as an UPRIGHT PORTRAIT HERO POSE — sitting or standing, body squared toward the viewer in a soft 3/4 turn, head HELD HIGH and alert, ears upright, gaze directed at the viewer (or slightly upward). The dog is facing the camera at eye level — NOT curled, NOT lying down, NOT viewed from above. - Head-and-shoulders / bust crop centred in the canvas. Long Italian Greyhound silhouette: slender neck, deep narrow chest, long muzzle, large eyes, folded rose-shaped ears. Preserve the breed identity, coat colour (soft grey-blue), eye colour, and characterful expression. Use the reference photo ONLY for the pet's identity (breed, coat, markings, eye colour, ears, expression). IGNORE the sofa, blanket, window, books, and surrounding environment entirely. Style requirements: - Refined black ink line drawing — confident, deliberate strokes with rich generous detail; substantial linework, NOT a sparse one-line minimalist sketch - Layered contour lines for fur direction, with closely-spaced parallel hatching for shadow depth under the chin, behind the ears, around the eyes - The eyes are the most detailed area — irises, pupils, eyelid lines, small reserved highlight as negative space - All lines pure black on flat #FFFFFF white — no off-white tint, no paper texture, no gradient, no halo Canvas + composition: - 1:1 square aspect, opaque PNG, pure flat #FFFFFF background, only the ink strokes carry darker pixels - Centre the bust portrait — head and shoulders fill the central composition with comfortable margins all around. Position the eyes at roughly the upper third of the canvas. - NO borders, frames, props, decorative elements, or text of any kind`; const body = { contents: [{ parts: [ { text: PROMPT }, { inline_data: { mime_type: 'image/jpeg', data: refB64 } }, ] }], generationConfig: { responseModalities: ['image', 'text'] }, }; console.log('→ Gemini render: after-juno-lineart.png (upright portrait override)'); const r = await fetch('https://generativelanguage.googleapis.com/v1beta/models/gemini-3-pro-image:generateContent', { method: 'POST', headers: { 'x-goog-api-key': GEMINI_KEY, 'content-type': 'application/json' }, body: JSON.stringify(body), }); if (!r.ok) { console.error(`${r.status}: ${(await r.text()).slice(0, 400)}`); process.exit(1); } const json = await r.json(); const parts = json?.candidates?.[0]?.content?.parts ?? []; let b64 = null; for (const part of parts) { const data = part?.inline_data?.data ?? part?.inlineData?.data; if (data) { b64 = data; break; } } if (!b64) { console.error('No image in response'); process.exit(1); } fs.writeFileSync(OUT_PATH, Buffer.from(b64, 'base64')); console.log(`✓ ${path.relative(ROOT, OUT_PATH)}`);