使用php怎么将图片等比例缩放

这篇文章给大家介绍使用php怎么将图片等比例缩放,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。

源代码如下:

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

关于使用php怎么将图片等比例缩放就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。