图片等比例缩放的计算公式


等比列计算公式:
百分比缩放
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
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM