
export function compressBase64Image(base64Image, compressionRatio) {
	return new Promise((resolve, reject) => {
	  const img = new Image();
	  img.src = base64Image;
	  img.onload = function() {
	    const canvas = document.createElement('canvas');
	    canvas.width = img.width * compressionRatio;
	    canvas.height = img.height * compressionRatio;
	    const ctx = canvas.getContext('2d');
	    ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
	    // 将Canvas上的图像转换为PNG格式的Base64
	    const compressedBase64 = canvas.toDataURL('image/png', 1);
	    resolve(compressedBase64);
	  };
			
	  img.onerror = function() {
	    reject("无法加载图像");
	  };
	});
}
