summaryrefslogtreecommitdiffstats
path: root/lib/utils/images.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/utils/images.js')
-rw-r--r--lib/utils/images.js16
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