How to convert byte array to image in Node.js? I tried the code below. It creates an image, but when I open it, an error message appears
Error interpreting JPEG image file.
I converted the byte array from the bitmap to Android and sent it to the Node server.
var mkdirp = require('mkdirp');
var fs = require('fs');
var bitmap = new Buffer(bytearray,'base64');
mkdirp(__dirname + "/images/",function(er)
{
if(er) console.log(er);
fs.writeFileSync(__dirname + "/images/"+profile._id+".jpeg",bitmap);
});
source
share