import puppeteer from 'puppeteer';
import fs from 'fs';
const svg = fs.readFileSync(process.argv[2], 'utf8');
const bg = process.argv[4] || '#0a0f0c';
const html = `<!doctype html><html><body style="margin:0;background:${bg};display:grid;place-items:center;height:100vh">${svg}</body></html>`;
const b = await puppeteer.launch({headless:'new', args:['--no-sandbox']});
const p = await b.newPage();
await p.setViewport({width:700, height:700, deviceScaleFactor:2});
await p.setContent(html, {waitUntil:'networkidle0'});
const el = await p.$('svg');
await el.evaluate(s=>{s.style.width='640px';s.style.height='640px';});
await p.screenshot({path: process.argv[3]});
await b.close();
console.log('shot →', process.argv[3]);
