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