Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

base64 nodejs image

var fs = require('fs');

// function to encode file data to base64 encoded string
function base64_encode(file) {
    // read binary data
    var bitmap = fs.readFileSync(file);
    // convert binary data to base64 encoded string
    return new Buffer(bitmap).toString('base64');
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #nodejs #image
ADD COMMENT
Topic
Name
8+4 =