35c76656e9
Runs Ghostscript on output/cover.pdf to produce output/cover-300dpi.png for visual QC and sharing. Also wired into the `pnpm all` pipeline. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
32 lines
911 B
JavaScript
32 lines
911 B
JavaScript
import { access, stat } from 'fs/promises';
|
|
import { resolve, dirname } from 'path';
|
|
import { fileURLToPath } from 'url';
|
|
import { execFile } from 'child_process';
|
|
import { promisify } from 'util';
|
|
|
|
const execFileAsync = promisify(execFile);
|
|
const __dir = dirname(fileURLToPath(import.meta.url));
|
|
const root = resolve(__dir, '..');
|
|
const pdfPath = resolve(root, 'output', 'cover.pdf');
|
|
const outPath = resolve(root, 'output', 'cover-300dpi.png');
|
|
|
|
try {
|
|
await access(pdfPath);
|
|
} catch {
|
|
console.error('output/cover.pdf not found — run `pnpm cover` first');
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log('Rendering cover to PNG at 300 DPI…');
|
|
|
|
await execFileAsync('gs', [
|
|
'-dBATCH', '-dNOPAUSE', '-dQUIET',
|
|
'-sDEVICE=png16m',
|
|
'-r300',
|
|
`-sOutputFile=${outPath}`,
|
|
pdfPath,
|
|
]);
|
|
|
|
const { size } = await stat(outPath);
|
|
console.log(`Cover image: output/cover-300dpi.png (${(size / 1_048_576).toFixed(1)} MB)`);
|