diff options
author | Samy Pesse <samypesse@gmail.com> | 2016-02-12 21:59:49 +0100 |
---|---|---|
committer | Samy Pesse <samypesse@gmail.com> | 2016-02-12 21:59:49 +0100 |
commit | 39b6562d1445e9a6c43a377d2a978eefa6458755 (patch) | |
tree | 77d530bca613c44e8c8fee8e6944d538d44f3ca7 /lib/utils/images.js | |
parent | 0d966fe19738089607de3927694ac5f2bd41f03f (diff) | |
download | gitbook-39b6562d1445e9a6c43a377d2a978eefa6458755.zip gitbook-39b6562d1445e9a6c43a377d2a978eefa6458755.tar.gz gitbook-39b6562d1445e9a6c43a377d2a978eefa6458755.tar.bz2 |
Add pipeline to outline svg as png
Diffstat (limited to 'lib/utils/images.js')
-rw-r--r-- | lib/utils/images.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/utils/images.js b/lib/utils/images.js index 3ba0f1f..45bc0b0 100644 --- a/lib/utils/images.js +++ b/lib/utils/images.js @@ -2,6 +2,7 @@ var fs = require('fs'); var Promise = require('./promise'); var command = require('./command'); +var fs = require('./fs'); var error = require('./error'); // Convert a svg file to a pmg @@ -21,7 +22,22 @@ function convertSVGToPNG(source, dest, options) { }); } +// Convert a svg buffer to a png file +function convertSVGBufferToPNG(buf, dest) { + // Create a temporary SVG file to convert + return fs.tmpFile({ + postfix: '.svg' + }) + .then(function(tmpSvg) { + return fs.writeFile(tmpSvg, buf) + .then(function() { + return convertSVGToPNG(tmpSvg, dest); + }); + }); +} + module.exports = { convertSVGToPNG: convertSVGToPNG, + convertSVGBufferToPNG: convertSVGBufferToPNG, INVALID: ['.svg'] };
\ No newline at end of file |