-
Notifications
You must be signed in to change notification settings - Fork 501
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #226 from faressoft/use-temp-rendering-dir
Fix: Use Temporary Directory for GIF Rendering (Fixes #216)
- Loading branch information
Showing
8 changed files
with
54 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,15 @@ | |
* @author Mohammad Fares <[email protected]> | ||
*/ | ||
|
||
const tmp = require('tmp'); | ||
|
||
tmp.setGracefulCleanup(); | ||
|
||
/** | ||
* The directory to render the frames into | ||
*/ | ||
var renderDir = tmp.dirSync({ unsafeCleanup: true }).name; | ||
|
||
/** | ||
* Create a progress bar for processing frames | ||
* | ||
|
@@ -80,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) { | ||
|
@@ -90,7 +99,6 @@ function getFrameDimensions() { | |
}; | ||
}); | ||
} | ||
|
||
/** | ||
* Render the frames into PNG images | ||
* | ||
|
@@ -115,7 +123,7 @@ function renderFrames(records, options) { | |
// Execute the rendering process | ||
var render = di.spawn( | ||
di.electron, | ||
[di.path.join(ROOT_PATH, "render/index.js"), options.step], | ||
[di.path.join(ROOT_PATH, "render/index.js"), renderDir, options.step,], | ||
{ detached: false } | ||
); | ||
|
||
|
@@ -205,7 +213,6 @@ function mergeFrames(records, options, frameDimensions) { | |
// Write the headers | ||
gif.writeHeader(); | ||
|
||
// Foreach frame | ||
di.async.eachOfSeries( | ||
records, | ||
function (frame, index, callback) { | ||
|
@@ -217,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) | ||
|
@@ -250,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(); | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters