'use strict'; const fs = require('fs'); const path = require('path'); const { spawn } = require('child_process'); const ROOT = path.resolve(__dirname, '..'); const CHROME = 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe'; const SIZE = 512; const svg = fs.readFileSync(path.join(ROOT, 'output', 'agent-avatars-png', 'avatars', 'bottts', 'bottts-001.svg'), 'utf8'); const html = `
${svg.replace('`; const hf = path.join(ROOT, 'output', '.tmp-test2.html'); fs.writeFileSync(hf, html, 'utf8'); const out = path.join(ROOT, 'output', 'test-t2.png'); const p = spawn(CHROME, [ '--headless=new', '--disable-gpu', '--hide-scrollbars', '--default-background-color=00000000', '--force-device-scale-factor=1', '--window-size=' + SIZE + ',' + SIZE, '--virtual-time-budget=1000', '--screenshot=' + out, 'file:///' + hf.replace(/\\/g, '/') ]); p.stdout.on('data', d => process.stdout.write('[out] ' + d)); p.stderr.on('data', d => process.stdout.write('[err] ' + d)); p.on('close', code => { console.log('exit code:', code); console.log('png exists:', fs.existsSync(out), fs.existsSync(out) ? fs.statSync(out).size : 0); });