From 2533271eca2615e3b99c9dbdb3ed69a77edf5996 Mon Sep 17 00:00:00 2001 From: Mohammad Fares Date: Sun, 9 Jul 2023 12:29:12 +0200 Subject: [PATCH] Render in the created temporry directory --- commands/render.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/commands/render.js b/commands/render.js index 905840b..1e188cb 100644 --- a/commands/render.js +++ b/commands/render.js @@ -5,6 +5,10 @@ * @author Mohammad Fares */ +const tmp = require('tmp'); + +tmp.setGracefulCleanup(); + /** * The directory to render the frames into */ @@ -85,7 +89,7 @@ function loadPNG(path) { */ function getFrameDimensions() { // The path of the first rendered frame - var framePath = di.path.join(ROOT_PATH, "render/frames/0.png"); + var framePath = di.path.join(renderDir, "0.png"); // Read and parse a PNG image file return loadPNG(framePath).then(function (png) { @@ -95,7 +99,6 @@ function getFrameDimensions() { }; }); } - /** * Render the frames into PNG images * @@ -210,7 +213,6 @@ function mergeFrames(records, options, frameDimensions) { // Write the headers gif.writeHeader(); - // Foreach frame di.async.eachOfSeries( records, function (frame, index, callback) { @@ -222,11 +224,7 @@ function mergeFrames(records, options, frameDimensions) { stepsCounter = (stepsCounter + 1) % options.step; // The path of the rendered frame - var framePath = di.path.join( - ROOT_PATH, - "render/frames", - index + ".png" - ); + var framePath = di.path.join(renderDir, index + ".png"); // Read and parse the rendered frame loadPNG(framePath) @@ -255,7 +253,7 @@ function mergeFrames(records, options, frameDimensions) { // Write the footer gif.finish(); - + // Finish console.log(di.chalk.green('[merge] Process successfully completed in ' + (Date.now() - start) + 'ms.')); resolve();