Using JavaScript-Load-Image function loadImage(...)
. But the base64 string is roughly 2-4x longer than loading it via FileReader()
.
I'm already dealing with large files so they cannot be so much larger.
var reader = new FileReader();
reader.onload = function() {
console.log('initial length:', this.result.length);
};
reader.readAsDataURL(image_file);
vs.
loadImage(
file,
function (img) {
console.log('resized length:', img.toDataURL().length);
},
{
orientation: true
}
);
some results:
24839 vs. 107482
2498383 vs. 5898430
2391783 vs. 5955498
img.toDataURL()
needed to beimg.toDataURL('image/jpeg)
to force saving as more compressed jpg instead of png