Php implements proportional scaling code such as images. _ PHP Tutorial

Source: Internet
Author: User
Php implements proportional scaling code such as images ,. Php real-time image proportional scaling code, new file index.php, and Q.jpg under the statistics Directory (you can change the image name based on the source code) source code: php $ fi php achieves proportional scaling code such as images,

The new file index.php contains a Q.jpg image in the statistics Directory (you can change the image name based on 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 some images and adjust imagecopyresized ($ new, $ img, 0, 0, $ n_w, $ n_h, $ width, $ height ); // Output new image, save as imagejpeg ($ new, "q1.jpg"); imagedestroy ($ new); imagedestroy ($ img);?>

After the browser is run, a q1.jpg image will be displayed in the directory at the same level of index.php. This image is an image scaled proportionally. you can change the path in the source code and put it in your project or write a method.

The above is all the content of this article. I hope it will be helpful for you to learn the php language.

New file index.php. the source code is as follows...

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.