php图片等比例缩放

<?php
$filename="./test1.jpg";
$per=0.5;
list($width, $height)=getimagesize($filename);
$n_w=$width*$per;
$n_h=$height*$per;
$new=imagecreatetruecolor($n_w, $n_h);
$img=imagecreatefromjpeg($filename);
//copy部分图像并调整
imagecopyresized($new, $img,0, 0,0, 0,$n_w, $n_h, $width, $height);
//图像输出新图片、另存为
imagejpeg($new, "./test11.jpg");
imagedestroy($new);
imagedestroy($img);
?>

原文地址:https://www.cnblogs.com/leku_cc/p/7452592.html