我想将图像转换为byte []。这就是我尝试过的
test({
event_handler: (data, cb) => {
console.log('Received event', data);
let fileName = `finger${Math.random() * 1000}.jpg`;
fs.writeFile(fileName, data, (err) => {
if (err) {
console.log(err)
}
//console.log(err);
let encodeImg = new Buffer(fileName, 'binary').toString('base64');
console.log(encodeImg);
var decodedImg = new Buffer(encodeImg, 'base64').toString('binary');
console.log(decodedImg);
event.sender.send('requestReceived', encodeImg,decodedImg );
fs.unlink(fileName);
});
cb();
}
}, );
encodeImg 的输出给出
ZmluZ2VyNDUwLjQwMTM1NDY4MTY3MDMuanBn
而不是将其作为字节数组。我需要做什么以这种格式:
0xFFD8FFE000104A46494600010101006000600000FFDB0043000806060706050807 ...