This commit is contained in:
@@ -486,7 +486,7 @@ export async function generateOgImages(contentDir, cacheDir, siteName, batchSize
|
|||||||
// Requires: pkg install resvg
|
// Requires: pkg install resvg
|
||||||
const outPath = join(ogDir, `${slug}.png`);
|
const outPath = join(ogDir, `${slug}.png`);
|
||||||
console.log(`[og] Generating: ${outPath}`);
|
console.log(`[og] Generating: ${outPath}`);
|
||||||
const result = spawnSync('resvg', ["-w", String(WIDTH), "-b", COLORS.bg, "-o", outPath, "-"], { input: svg, encoding: null });
|
const result = spawnSync("resvg", ["-w", String(WIDTH), "-b", COLORS.bg, "-o", outPath, "-"], { input: svg, encoding: null });
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
console.error(`[og] resvg CLI error for ${outPath}:`, result.error);
|
console.error(`[og] resvg CLI error for ${outPath}:`, result.error);
|
||||||
throw result.error;
|
throw result.error;
|
||||||
@@ -495,10 +495,6 @@ export async function generateOgImages(contentDir, cacheDir, siteName, batchSize
|
|||||||
console.error(`[og] resvg CLI failed for ${outPath}:`, result.stderr && result.stderr.toString());
|
console.error(`[og] resvg CLI failed for ${outPath}:`, result.stderr && result.stderr.toString());
|
||||||
throw new Error(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}`);
|
console.log(`[og] Wrote: ${outPath}`);
|
||||||
newManifest[slug] = { title: slug, hash };
|
newManifest[slug] = { title: slug, hash };
|
||||||
generated++;
|
generated++;
|
||||||
@@ -507,25 +503,6 @@ export async function generateOgImages(contentDir, cacheDir, siteName, batchSize
|
|||||||
if (generated % SAVE_INTERVAL === 0) {
|
if (generated % SAVE_INTERVAL === 0) {
|
||||||
writeFileSync(manifestPath, JSON.stringify(newManifest, null, 2));
|
writeFileSync(manifestPath, JSON.stringify(newManifest, null, 2));
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
const result = spawnSync('resvg', ["-w", String(WIDTH), "-b", COLORS.bg, "-o", outPath, "-"], { input: svg, encoding: null });
|
|
||||||
if (result.error) {
|
|
||||||
console.error(`[og] resvg CLI error for ${outPath}:`, result.error);
|
|
||||||
throw result.error;
|
|
||||||
}
|
|
||||||
if (result.status !== 0) {
|
|
||||||
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}`);
|
|
||||||
} catch (e) {
|
|
||||||
console.error(`[og] Exception for ${outPath}:`, e);
|
|
||||||
require('fs').writeFileSync(outPath.replace(/\.png$/, '.svg'), svg);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Force GC to reclaim Satori/Resvg WASM native memory.
|
// Force GC to reclaim Satori/Resvg WASM native memory.
|
||||||
if (hasGC && generated % GC_INTERVAL === 0) {
|
if (hasGC && generated % GC_INTERVAL === 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user