Phpthumb Picture Processing Use detailed

Source: Internet
Author: User
This time to everyone to bring phpthumb picture processing use detailed, phpthumb picture processing use of the attention to what, the following is the actual case, together to see.

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:

<?php//Load Class library file require_once ' path/to/thumblib.inc.php ';//Instantiate the class library, and the address of the image you want to process can be a network address or a local address $thumb = Phpthumbfactory::create (' http://www.jbxue.com/');//reduce the picture to a maximum width of 100px or up to 100px, when only one parameter is entered, the widest size is limited. $thumb->resize (100, 100);//reduce the picture to the original percentage, such as 50 is the original 50%. $thumb->resizepercent (50);//Capture a 175px * 175px picture, note that this is the interception, the part of the excess directly cut off, is not forced to change the size. $thumb->adaptiveresize (175, 175);//from the center of the image, capture 200px * 100px images. $thumb->cropfromcenter (200, 100);//, the first two parameters are the coordinates x, y of the upper-right corner of the picture to be solved, respectively. The following two parameters are required to solve the picture width, height. $thumb->crop (100, 100, 300, 200);//invert the picture clockwise by 180 degrees $thumb->rotateimagendegrees (180);//save (Generate) picture, you can save the other format, detailed reference document $thumb->save (' newpath/of/image.jpg ');

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
In addition to scaling the picture, the class can also convert the picture to 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 the following files are required:

We'll be using Phpthumb, the open source PHP script to generate thumbnails on the fly. Download and extract Phpthumb to somewhere in your website folder. Now to use a rounded corner thumbnail of an image, simply use the IMG tag of HTML with SRC as Adjust the path to Phpthumb according to where you pl Ace the Phpthumb files.

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

SRC: Address of the target image
W: the width of the output picture
H: The height of the output image (if not specified he will be scaled by the W parameter, etc.)
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, wide height, starting position
F: Output format, can be JPEG, PNG, GIF, ICO
SFN: Output A frame in an animated GIF
Fltr[]: Filters, can have a lot of effects, including sharpening, Blur, spin flip, watermark, border, matte, color adjustment, etc.

Believe that you have read the case of this article you have mastered the method, more exciting please pay attention to the PHP Chinese network other related articles!

Recommended reading:

PHP English letter case conversion how to implement

PHP generates a string of random numbers, letters, or numbers mixed with letters

Related Article

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.