1

whith this code :

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);

i save a img send by the client. the problem is that the image saved weighs a lot more than the original sent by the client. there is a way to decrease the weighs of the image saved?

OrangeDog
  • 36,653
  • 12
  • 122
  • 207
Alessandro Zago
  • 793
  • 3
  • 12
  • 33
  • Possible duplicate of [How to resize image in Node js](http://stackoverflow.com/q/37115815/476716). – OrangeDog Jun 09 '16 at 13:04
  • This is strange, because base64 usually produces much larger data than pre-encoded. Have you checked if image written to disk is still valid? Also check this answer: http://stackoverflow.com/a/6933413/6352710 – ahwayakchih Jun 09 '16 at 13:22

0 Answers0