Get the App
SLTechnology News&Howtos  ›  Development  › 

How to generate thumbnail classes with adaptive size by PHP

Shulou Source: shulou.com Published: 2022-06-03 15:47:12 11月14日 Update

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!

Tags: Code size generation file learning maximum content picture path almost generally speaking personality usage key uppercase width that is idea situation file name Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Docker vpn Shulou Information Linux