Package Exports
- base64image-to-file
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (base64image-to-file) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
base64image-to-file
The module takes a base64 encoded image string(i.e data-url) and creates an image file from it.
Install
$ npm install base64image-to-file --saveUsage
var base64ImageToFile = require('base64image-to-file');
var base64Image = 'data:image/gif;base64,R0lGODdhMgAyAOM...';
// create an image with the a given name ie 'image'
base64ImageToFile(base64Image, '/tmp/', 'image', function(err) {
if(err) {
return console.error(err);
}
console.log(imgPath);
});
// create an image with the a random name(basically hex string)
base64ImageToFile(base64Image, '/tmp/', function(err) {
if(err) {
return console.error(err);
}
console.log(imgPath);
});API
base64ImageToFile(base64String, dirPath [, imageName], cb)
base64String
Type: String
This should be a base64 encoded string.
dirPath
Type: String
Directory to create the image in.
imageName(Optional)
Type: String
Name to give the created file, otherwise it is given a random name
cb
Type: Function
Callback function with signature cb(err, imgPath).
License
MIT.
