How to generate thumbnail classes with adaptive size by PHP
This article mainly explains "how PHP generates thumbnail classes of adaptive size". The explanation in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian slowly and deeply to study and learn "how PHP generates thumbnail classes of adaptive size" together!
Copy the following code directly and create a new file called thumbnailimage.php. The file name should not be capitalized. Copy the following code into it:
The copy code is as follows:
How to use:
1. Reference the PHP file first (don't tell me not to)
2. Call code
The copy code is as follows:
$tis = new ThumbnailImage();
$tis->src_file = "write path of source file here"
$tis->dest_type = THUMB_JPEG;//the type of generated image is jpg
$tis->dest_file = 'write the path of the target file here';
$tis->max_width = 120;//Adaptive size, but maximum width is 120
$tis->max_height = 4000; //Adaptive size, but maximum height is 4000
$tis->Output();
The key to the code is max_width and max_height, how much to fill in, it will help you generate a file of about the same size, in general, unless your picture is very personal, such as very long, otherwise the thumbnail generated is still very considerate.
Thank you for reading, the above is "PHP how to generate adaptive size thumbnail class" content, after the study of this article, I believe we have a deeper understanding of how PHP generates adaptive size thumbnail class, the specific use of the situation also needs to be verified. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!