Skip to content

Instantly share code, notes, and snippets.

View gixxerblade's full-sized avatar
💭
Cycling

Stephen Clark gixxerblade

💭
Cycling
View GitHub Profile
@gixxerblade
gixxerblade / gist:345e6b7810a1c0a7e5b77662905a52f4
Created June 9, 2022 14:06 — forked from crspiccin/gist:790796a68e7178404de4
Node.js convert an image to Base 64
//http://www.hacksparrow.com/base64-encoding-decoding-in-node-js.html
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');
}