PHP implementation of Image scale scaling code,
New file index.php, need to have a picture in the statistics directory is q.jpg (can change the name of the picture according to the source code)
The source code is as follows:
<?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);//Copy part of the image and adjust imagecopyresized ($new , $img, 0, 0,0, 0, $n _w, $n _h, $width, $height);//image output new picture, Save as imagejpeg ($new, "q1.jpg"); Imagedestroy ($new); Imagedestroy ( $IMG);? >
After using the browser to run, in the index.php sibling directory will have a q1.jpg, this picture is the scale of the image, the path can be changed in the source code itself, put in their own projects or write a method also line
The above mentioned above is the whole content of this article, I hope to learn PHP language for everyone to be helpful.
http://www.bkjia.com/PHPjc/1037589.html www.bkjia.com true http://www.bkjia.com/PHPjc/1037589.html techarticle PHP Implementation of the picture, such as proportional scaling code, the new file index.php, you need to have a picture in the statistics directory for q.jpg (can change the name of the picture according to the source code) as follows: Php$fi ...