function compressImage(file){
let cvs = document.getElementById('compress-canvas');
let newImage = new Image();
let fileCache = file;
newImage.src = file.content;
newImage.onload = () => {
if (newImage.complete) {
cvs.width = newImage.naturalWidth;
cvs.height = newImage.naturalHeight;
cvs.getContext('2d').drawImage(newImage, 0, 0, newImage.naturalWidth, newImage.naturalHeight);
const newImageData = cvs.toDataURL(mime_type, 0.5);
// newImageData 居然为data:;
}
};
}
naturalWidth和naturalHeight的原因,替换成width和height就行了