calculate size of base64 image from buffer, still not perfect but better than string.length
This commit is contained in:
Barış Soner Uşaklı
2018-09-20 19:47:44 -04:00
parent 352bea9475
commit 71ccd67665
3 changed files with 11 additions and 4 deletions

View File

@@ -125,3 +125,7 @@ image.writeImageDataToTempFile = function (imageData, callback) {
callback(err, filepath);
});
};
image.sizeFromBase64 = function (imageData) {
return Buffer.from(imageData.slice(imageData.indexOf('base64') + 7), 'base64').length;
};