Php image proportional scaling, _ PHP Tutorial

Source: Internet
Author: User
Php image scaling ,. PHP image proportional scaling, new file index.php, or Q.jpg under the statistics Directory (you can change the image name based on the source code) source code is as follows :? Php $ filenameq. php image proportional scaling,

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:

$ 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 and adjust part of the image
Imagecopyresized ($ new, $ img, 0, 0, 0, $ n_w, $ n_h, $ width, $ height );
// Output new image and save it
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.

Example: the new file index.php has an image named Q.jpg in the statistics Directory (you can change the image name based on the source code). the source code is as follows :? Php $ filename = "q ....

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.