File size: 1,048 Bytes
142b604 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | const fs = require('fs')
const path = require('path')
const demoDataFile = path.join(__dirname, '..', 'src', 'lib', 'demo-data.js')
const content = fs.readFileSync(demoDataFile, 'utf8')
const beforeMatch = content.match(/DEMO_BEFORE_IMAGE\s*=\s*['"]data:image\/png;base64,([^'"]+)['"]/)
const afterMatch = content.match(/DEMO_AFTER_IMAGE\s*=\s*['"]data:image\/png;base64,([^'"]+)['"]/)
if (!beforeMatch || !afterMatch) {
console.error('[write-samples] Failed to extract base64 data URLs from demo-data.js')
process.exit(1)
}
const samplesDir = path.join(__dirname, '..', 'public', 'samples')
fs.mkdirSync(samplesDir, { recursive: true })
const beforeBuf = Buffer.from(beforeMatch[1], 'base64')
const afterBuf = Buffer.from(afterMatch[1], 'base64')
fs.writeFileSync(path.join(samplesDir, 'background-removal-before.png'), beforeBuf)
fs.writeFileSync(path.join(samplesDir, 'background-removal-after.png'), afterBuf)
console.log(`[write-samples] Wrote real binary PNG samples: before (${beforeBuf.length} B), after (${afterBuf.length} B)`)
|