Node.js 节点保存质量较低的图像
使用此代码:Node.js 节点保存质量较低的图像,node.js,image-resizing,Node.js,Image Resizing,使用此代码: var img = req.body.img; var data = img.replace(/^data:image\/\w+;base64,/, ""); var buf = new Buffer(data, 'base64'); var nomeFile = Date.now()+"-"+req.session.documentoAperto+".png" fs.writeFile('/root/appsistMe/public/AppMeFile/Utenti/'+req
var img = req.body.img;
var data = img.replace(/^data:image\/\w+;base64,/, "");
var buf = new Buffer(data, 'base64');
var nomeFile = Date.now()+"-"+req.session.documentoAperto+".png"
fs.writeFile('/root/appsistMe/public/AppMeFile/Utenti/'+req.session.nome+'/'+req.session.documentoAperto+'/'+nomeFile, buf);
我保存了客户发送的img。
问题是保存的图像比客户端发送的原始图像重很多。
有一种方法可以减少保存的图像的重量?可能的重复。这很奇怪,因为base64通常生成比预编码的数据大得多的数据。您是否检查了写入磁盘的映像是否仍然有效?还要检查这个答案:的可能重复。这很奇怪,因为base64通常生成比预编码的数据大得多的数据。您是否检查了写入磁盘的映像是否仍然有效?请检查以下答案: