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:
- Loading class library files
- Require_once ' path/to/thumblib.inc.php ';
- 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
- $thumb = phpthumbfactory::create (' http://bbs.it-home.org/');
- 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);
- 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.
- $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 that needs to be solved. 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) pictures, you can save other formats, detailed reference documents
- $thumb->save (' newpath/of/image.jpg ');
Copy CodeThis 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:
- 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. 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 place the Phpthumb files.
Copy CodeIn 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. |