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

php图片等比例缩放函数

WBOY
Release: 2016-06-20 13:03:29
Original
985 people have browsed it

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>
Copy after login


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template