等比例縮放尺寸怎么算?
等比列計算公式:
百分比縮放
const imgPect = (picture_width, picture_height, default_width, default_height) => {
var widthRatio = default_width / picture_width
var heightRatio = default_height / picture_height
var ratio
widthRatio < heightRatio ? ratio = widthRatio : ratio = heightRatio
var currentImg = { picture_width: parseInt(picture_width * ratio), picture_height: parseInt(picture_height * ratio)}
return currentImg