What does thumbs mean? PHPThumb PHP Image Thumbnail Gallery

WBOY
Release: 2016-07-29 08:48:11
Original
2285 people have browsed it

1. This is a thumbnail class library
It is an open source picture thumbnail class library that can complete a variety of complex picture thumbnail generation and reality, and is very convenient to use.
2. Usage
Here is a simple and practical explanation about it. The English is relatively simple and will not be translated:
Basic-Usage
3. API
Here is a list of APIs:
PHPThumb API
But it is a pity that in the API There is no explanation. You can only guess its effect based on its English name. Of course, even if you guess it right, you have to test it to see if it is correct.
4. Example
Here I also wrote a simple method to call it, but I saved the image as a file. The examples in basic-usage are all output directly on the page:

Copy the code The code is as follows:


require_once 'phpthumb/ThumbLib.inc.php';
try {
$thumb = PhpThumbFactory::create($realpath);
} catch (Exception $e) {
// handle error here however you'd like
}
$thumb->adaptiveResize($width, $height);
$thumb->save($realpath . '.' . $width . 'x' . $height . '.png ');


5. Several APIs I used
In the process of using them, my understanding of several APIs gradually deepened. I record them here:
resize ($maxWidth, $maxHeight)
resize method is the most commonly used reduction method. The thumbnail method directly reduces the largest side to the required height/width proportionally. When the aspect ratio of the picture is inconsistent with the requirements, one side will be blank.
adaptiveResize ($width, $height)
adaptiveResize method does not require the completeness of the image under certain circumstances, but requires that the maximum content of a specific width and height be displayed. The specific calculation method is:
When the width of the picture is greater than the required width and the height is the same, take the height and go to the required width from the middle of the left and right sides of the picture;
When the height of the picture is larger and the width is the same, go to the width Next, center the top and bottom of the image to obtain the required height;
When the width and height are incorrect, first scale the image to the required size, and then execute the first two steps.
save ($fileName, $format = 'GIF|JPG|PNG')
After the image is processed, you can use the save method to save the image as one of the encodings indicated in format. If no encoding is specified, it will Save in original encoding. $fileName is the path to save.

The above has introduced what thumbs means. PHPThumb PHP picture thumbnail gallery, including what thumbs means. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template