What does thumbs mean? Phpthumb PHP image thumbnail gallery

Source: Internet
Author: User
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 the Code code 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.

The above describes what thumbs means phpthumb php image thumbnail library, including what is the meaning of thumbs content, I hope to be interested in PHP tutorial friends helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.