Created
September 24, 2014 21:33
-
-
Save miguelmota/4e9864f182c053d7a51d to your computer and use it in GitHub Desktop.
Base64 to PNG in Node.js
This file contains hidden or 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
var fs = require('fs'); | |
var path = require('path'); | |
function base64ToPNG(data) { | |
data = data.replace(/^data:image\/png;base64,/, ''); | |
fs.writeFile(path.resolve(__dirname, '../tmp/image.png'), data, 'base64', function(err) { | |
if (err) throw err; | |
}); | |
} | |
module.exports = base64ToPNG; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment