From 277e96f0f7423537abef07b76bd6ddd73ca9743b Mon Sep 17 00:00:00 2001 From: java110 <928255095@qq.com> Date: Sun, 30 May 2021 09:37:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BE=E7=89=87=E5=8E=8B=E7=BC=A9=E6=97=B6?= =?UTF-8?q?=20=E4=B8=8D=E8=83=BD=E5=A4=A7=E4=BA=8E1080?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/translate-image.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/utils/translate-image.js b/utils/translate-image.js index 2c38847..e0518cc 100644 --- a/utils/translate-image.js +++ b/utils/translate-image.js @@ -21,8 +21,20 @@ export function translate(imgSrc, callback) { var h = that.height; // 默认按比例压缩 - var w = that.width; + + if(h > 1080 || w > 1080){ + let _rate = 0; + if(h > w){ + _rate = h/1080; + h = 1080; + w = Math.floor(w/_rate); + }else{ + _rate = w/1080; + w = 1080; + h = Math.floor(h/_rate); + } + } var canvas = document.createElement('canvas');