diff --git a/lib/server/imageGenerator.js b/lib/server/imageGenerator.js index 9b36841..fb874ff 100644 --- a/lib/server/imageGenerator.js +++ b/lib/server/imageGenerator.js @@ -29,8 +29,9 @@ class ImageGenerator { const absolutePath = path_1.default.join(this.outDir, imageName); const relativePath = path_1.default.join('/', this.args.dir, absolutePath.slice(this.outDir.length)); const svg = await this.satori(element, options); - const pngBuffer = new resvg_js_1.Resvg(svg).render().asPng(); - fs.writeFileSync(absolutePath, pngBuffer); + const resvg = new resvg_js_1.Resvg(svg); + const pngOutput = resvg.render(); + await fsp.writeFile(absolutePath, pngOutput.asPng()); const url = new URL(this.args.websiteUrl); url.pathname = relativePath; this.cache[hash] = { diff --git a/src/server/imageGenerator.ts b/src/server/imageGenerator.ts index 62d500e..8c48e1e 100644 --- a/src/server/imageGenerator.ts +++ b/src/server/imageGenerator.ts @@ -54,8 +54,9 @@ export class ImageGenerator { ) const svg = await this.satori(element, options) - const pngBuffer = new Resvg(svg).render().asPng(); - fs.writeFileSync(absolutePath, pngBuffer); + const resvg = new Resvg(svg); + const pngOutput = resvg.render(); + await fsp.writeFile(absolutePath, pngOutput.asPng()); const url = new URL(this.args.websiteUrl) url.pathname = relativePath