-
-
Save cesarferreira/c9e05cfd0e66b6d1c79ef88208b773b9 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