This commit is contained in:
@@ -485,17 +485,21 @@ export async function generateOgImages(contentDir, cacheDir, siteName, batchSize
|
|||||||
// Render SVG to PNG using the system resvg CLI
|
// Render SVG to PNG using the system resvg CLI
|
||||||
// Requires: pkg install resvg
|
// Requires: pkg install resvg
|
||||||
const outPath = join(ogDir, `${slug}.png`);
|
const outPath = join(ogDir, `${slug}.png`);
|
||||||
const resvgProc = spawnSync(
|
console.log(`[og] Generating: ${outPath}`);
|
||||||
"resvg",
|
const result = spawnSync('resvg', ["-w", String(WIDTH), "-b", COLORS.bg, "-o", outPath, "-"], { input: svg, encoding: null });
|
||||||
["-w", String(WIDTH), "-b", COLORS.bg, "-o", outPath, "-"],
|
if (result.error) {
|
||||||
{ input: svg, encoding: null }
|
console.error(`[og] resvg CLI error for ${outPath}:`, result.error);
|
||||||
);
|
throw result.error;
|
||||||
if (resvgProc.error) {
|
|
||||||
throw resvgProc.error;
|
|
||||||
}
|
}
|
||||||
if (resvgProc.status !== 0) {
|
if (result.status !== 0) {
|
||||||
throw new Error(`resvg CLI failed: ${resvgProc.stderr?.toString()}`);
|
console.error(`[og] resvg CLI failed for ${outPath}:`, result.stderr && result.stderr.toString());
|
||||||
|
throw new Error(result.stderr && result.stderr.toString());
|
||||||
}
|
}
|
||||||
|
if (!result.stdout || result.stdout.length === 0) {
|
||||||
|
console.error(`[og] resvg CLI produced no output for ${outPath}`);
|
||||||
|
throw new Error('resvg CLI produced no output');
|
||||||
|
}
|
||||||
|
console.log(`[og] Wrote: ${outPath}`);
|
||||||
newManifest[slug] = { title: slug, hash };
|
newManifest[slug] = { title: slug, hash };
|
||||||
generated++;
|
generated++;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user