if($toWH<=$srcWH){
$ftoW=$toW;
$ftoH=$ftoW*($srcH/$srcW);
}
else{
$ftoH=$toH;
$ftoW=$ftoH*($srcW/$srcH);
}
更改为
$ftoH=$toH;
$ftoW=$toW;
if ($toWH<=$srcWH) {
$src_Y = 0;
$src_X = ($srcW-$srcH*$toWH)/2;
$srcW = $srcH*$toWH;
} else {
$src_X = 0;
$src_Y = ($srcH-$srcW/$toWH)/2;
$srcH = $srcW/$toWH;
}
($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH)
更改为
($ni,$im,0,0,$src_X,$src_Y,$ftoW,$ftoH,$srcW,$srcH)
其实就一小小改动,就是在原图中截取最大面积的符合自定义缩略图长宽比列的一部分生成缩略图。相关文章
热门资讯