Php dynamically generates thumbnails and outputs the display method. The following describes how to dynamically generate and display thumbnails in php and how to output and display thumbnails in php. it involves some php image-related skills, very practical value: php dynamic generation of thumbnails and output of display methods
The following describes how to dynamically generate and display thumbnails in php. it involves some php image-related skills and is very useful. For more information, see
This example describes how php dynamically generates thumbnails and outputs the display. Share it with you for your reference. The details are as follows:
Call method:
?
This code dynamically generates thumbnail display for large images. images are generated in the memory and are not generated on the hard disk.
The thumbs. php file is as follows:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
$ Filename = $ _ GET ['filename']; $ Width = $ _ GET ['width']; $ Height = $ _ GET ['height']; $ Path = "http: // localhost/images/"; // finish in "/" // Content type Header ('content-type: image/jpeg '); // Get new dimensions List ($ width_orig, $ height_orig) = getimagesize ($ path. $ filename ); If ($ width & ($ width_orig <$ height_orig )){ $ Width = ($ height/$ height_orig) * $ width_orig; } Else { $ Height = ($ width/$ width_orig) * $ height_orig; } // Resample $ Image_p = imagecreatetruecolor ($ width, $ height ); $ Image = imagecreatefromjpeg ($ path. $ filename ); Imagecopyresampled ($ image_p, $ image, 0, 0, 0, $ width, $ height, $ width_orig, $ height_orig ); // Output Imagejpeg ($ image_p, null, 100 ); // Imagedestroy Imagedestroy ($ image_p ); ?> |
I hope this article will help you with php programming.
The following section describes how to dynamically generate thumbnails and display thumbnails in php. it involves php image-related skills and is very useful...