PHP implementation of image scaling code, _php tutorial

Source: Internet
Author: User

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 ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.