使用JavaScript-Load-Image函数loadImage(...)
。但是 base64 字符串比通过加载它大约长 2-4 倍FileReader()
。
我已经在处理大文件,所以它们不可能大得多。
var reader = new FileReader();
reader.onload = function() {
console.log('initial length:', this.result.length);
};
reader.readAsDataURL(image_file);
对比
loadImage(
file,
function (img) {
console.log('resized length:', img.toDataURL().length);
},
{
orientation: true
}
);
一些结果:
24839 与 107482
2498383 与 5898430
2391783 与 5955498