1

使用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

4

1 回答 1

0

img.toDataURL()需要img.toDataURL('image/jpeg)强制保存为更压缩的 jpg 而不是 png

于 2017-01-05T20:18:14.907 回答