Home  >  Article  >  Backend Development  >  php图片等比例缩放函数

php图片等比例缩放函数

WBOY
WBOYOriginal
2016-06-20 13:03:29969browse

php图片等比例缩放函数

源代码如下:

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


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn