zhouandtao 发表于 2017-4-11 12:17:18

php 按最大尺寸 等比例缩放图片

$maxWidth = 180;//最大宽度
$maxHeight = 125;   //最大高度
$iSuofang = $arrPicwh['w']/$arrPicwh['h'];//原图的比例
$iSuo = $arrPicwh['h']/$arrPicwh['w'];
if ($arrPicwh['w'] > $arrPicwh['h'])//判断原图的宽高那个大
{
$dstW = $maxWidth;
$dstH = $maxWidth * $iSuo;
}else
{
$dstH = $maxHeight;
$dstW = $maxHeight * $iSuofang;
}
 
页: [1]
查看完整版本: php 按最大尺寸 等比例缩放图片