Phpthumb Image Processing Example parsing

Source: Internet
Author: User

Download address (GITHUB.COM/MASTEREXPLODER/PHPTHUMB). Note that this class library has a name called Phpthumb, only the difference in capitalization, so be careful when looking for documents. Processing pictures in a number of places, with the PHP picture function processing pictures, very cumbersome. And very difficult for beginners to master. can use the Phpthumb class library to handle the picture, including, image resizing, image interception, image plus watermark, image rotation and other functions.

Example:

    1. Loading class library files
    2. Require_once ' path/to/thumblib.inc.php ';
    3. Instantiate the class library, the address of the image you want to work with can be a network address, or it can be a local address
    4. $thumb = phpthumbfactory::create (' http://bbs.it-home.org/');
    5. Reduce the picture to a maximum width of 100px or up to 100px, when only one parameter is entered, the widest size is limited.
    6. $thumb->resize (100, 100);
    7. Reduce the picture to the original percentage, such as 50 is the original 50%.
    8. $thumb->resizepercent (50);
    9. Intercept a 175px * 175px picture, note that this is the intercept, the part of the excess is cut off directly, is not forced to change the size.
    10. $thumb->adaptiveresize (175, 175);
    11. From the center of the image, capture 200px * 100px images.
    12. $thumb->cropfromcenter (200, 100);
    13. , the first two parameters are the coordinates x, y of the upper-right corner of the picture that needs to be solved. The following two parameters are required to solve the picture width, height.
    14. $thumb->crop (100, 100, 300, 200);
    15. Invert the picture clockwise by 180 degrees.
    16. $thumb->rotateimagendegrees (180);
    17. Save (Generate) pictures, you can save other formats, detailed reference documents
    18. $thumb->save (' newpath/of/image.jpg ');
Copy Code

This class library has more features to do not introduce, if you are also in the process of developing PHP Web site need to handle the picture, you can read this class library document, to ensure that you handle the picture is very simple, no longer with the more than 10 annoying PHP image processing function!

Another powerful PHP image thumbnail class: Phpthumb the class in addition to scaling the picture, but also to convert the picture to a different format output (such as the GIF format of the image output to PNG format), its features include color, special effects and so on. Official website: http://phpthumb.sourceforge.net/generally only need the following documents to be able to:

    1. We'll be using Phpthumb, the open source PHP script to generate thumbnails on the fly.
    2. Download and extract Phpthumb to somewhere in your website folder. Rounded corner thumbnail of an image, simply use the IMG tag of HTML with SRC as
    3. Adjust the path to Phpthumb according to where you place the Phpthumb files.
Copy Code

In fact, the function of phpthumb than I originally thought to be more powerful, below some of his other useful parameters are listed:

SRC: The address of the target image w: the width of the output picture h: The height of the output picture (if not specified he will be scaled by the W parameter) Q: If the output is in JPG format, you can specify its output quality bg: background when output (if required) SW, SH, SX, SY: Local output, Width high, Start position F: Output format, can be JPEG, PNG, GIF, ICOSFN: Output A frame of GIF animation fltr[]: filter, can have many effects, including sharpening, blur, flip, watermark, border, matte, color adjustment, etc.
  • 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.