This article mainly introduces how php dynamically generates thumbnails and outputs the display. it involves php image-related skills and is very useful, for more information, see the example in this article. 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:
<?php$filename= $_GET['filename'];$width = $_GET['width'];$height = $_GET['height'];$path="http://localhost/images/"; //finish in "/"// Content typeheader('Content-type: image/jpeg');// Get new dimensionslist($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,0,$width,$height,$width_orig,$height_orig);// Outputimagejpeg($image_p, null, 100);// Imagedestroyimagedestroy ($image_p);?>
I hope this article will help you with php programming.