1, this is a thumbnail class library
It is an open source image Thumbnail class library, can complete a variety of complex image thumbnail generation and reality, very convenient to use.
2. How to use
Here is a simple and practical explanation, English is relatively simple, do not translate:
Basic-usage
3. API
Here is a list of APIs:
Phpthumb API
Unfortunately, the API does not have any explanation, can only compare its English name to guess its effect, of course, even if the right to guess, but also to test to see if it is correct.
4. Examples
Here I also wrote a simple way to call it, but I saved the picture as a file, basic-usage in the example is all directly in the page output:
Copy CodeThe 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 that I used
In the course of use, the understanding of several APIs deepens, as recorded here:
Resize ($maxWidth, $maxHeight)
Resize method is the most commonly used thumbnail method, it directly proportional to the largest edge narrowed to meet the required height/width, when the picture aspect ratio and the requirements are inconsistent, there will be a blank side display.
Adaptiveresize ($width, $height)
The Adaptiveresize method is that in some specific cases, the picture is not required to be complete, and the maximum content of a particular wide height is required to be displayed. The exact calculation is as follows:
When the width of the picture is greater than the required width, and the height of the same, take that height, from the middle of the picture left and right to the required width;
When the height of the picture and the width of the same, go to the width, the picture up and down the center of the position to obtain the required height;
When the width is not correct, the picture is scaled to the required size, and then the first two is executed.
Save ($fileName, $format = ' gif| Jpg| PNG ')
When you are done with the image, you can save the image as one of the encodings indicated in format by using the Save method, and if no encoding is specified, it will be saved as the original encoding. $fileName is the path to save.
http://www.bkjia.com/PHPjc/325255.html www.bkjia.com true http://www.bkjia.com/PHPjc/325255.html techarticle 1, this is a thumbnail class library it is an open source image thumbnail class library, you can complete a variety of complex image thumbnail generation and reality, very convenient to use. 2. How to use ...