PHPThumbPHP image thumbnail library. 1. this is a thumbnail class library. it is an open-source image thumbnail class library that can be used to generate and implement various complex image thumbnails. 2. usage
1. this is a thumbnail class library.
It is an open-source image thumbnail library that can be used to generate and implement various complex image thumbnails.
2. usage
Here is a simple and practical description about it. The English is relatively simple and will not be translated:
Basic-Usage
3. API
Here is a list of APIs:
PHPThumb API
However, it is a pity that there is no explanation in the API, and you can only guess the effect based on the English name. of course, even if you guessed it right, you should test whether 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:
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 use
During usage, the understanding of several APIs is gradually deepened. here we record:
Resize ($ maxWidth, $ maxHeight)
The resize method is the most commonly used thumbnail method, which directly scales down the maximum side to the required height/width. when the aspect ratio of the image is different from the requirement, the edges are blank.
AdaptiveResize ($ width, $ height)
The adaptiveResize method is used to display the largest content with a specified width and height, but does not require Image integrity in certain situations. The calculation method is as follows:
When the image width is greater than the required width and the height is the same, take the width required from the middle of the image to the bottom of the height;
When the image height is large and the width is the same, go to the width and the image is centered up and down to obtain the required height;
When the width and height are incorrect, first scale the image to the required size, and then follow the first two steps.
Save ($ fileName, $ format = 'gif | JPG | PNG ')
After processing the image, you can use the save method to save the image as one of the encoding indicated in the format. If no encoding is specified, it will be saved as the original encoding. $ FileName is the path to save.
It is an open-source image thumbnail library that can be used to generate a variety of complex image thumbnails and make it easy to use. 2. usage...