|
(Github.com/masterexploder/PHPThumb ). Note that this class library is named phpThumb with the same name as it is case-sensitive, so pay attention to it when searching documents. There are a lot of places to process images. it is very tedious to use the PHP image function to process images. It is very difficult for new users to master. You can use the PHPThumb class library to process images, including image size adjustment, image capturing, Image watermarking, and image rotation.
Example:
- // Load the class library file
- Require_once 'path/to/ThumbLib. inc. php ';
- // Instantiate the class library. the address of the image you want to process can be a network address or a local address.
- $ Thumb = PhpThumbFactory: create ('http: // bbs.it-home.org /');
- // Scale down the image to a maximum width of PX or a maximum of px. when only one parameter is input, the maximum width is limited.
- $ Thumb-> resize (100,100 );
- // Reduce the image proportional ratio to the original percentage. for example, 50 is the original 50%.
- $ Thumb-> resizePercent (50 );
- // Intercept a 175px * 175px Image. Note that this is the intercept. the excess part is directly cropped, not forcibly changed.
- $ Thumb-> adaptiveResize (175,175 );
- // Extract a PX * px image from the image center.
- $ Thumb-> cropFromCenter (200,100 );
- // The first two parameters are the coordinates X and Y in the upper-right corner of the image to be extracted. The following two parameters are the width and height of the image to be solved.
- $ Thumb-> crop (100,100,300,200 );
- // Reverse the image clockwise to 180 degrees
- $ Thumb-> rotateImageNDegrees (180 );
- // Save (generate) the image. you can save other formats. For more information, see.
- $ Thumb-> save ('newpath/Of/image.jpg ');
There are more functions in this class library. if you need to process images when developing a PHP website, read the documentation of this class library to ensure that you can process images easily, you no longer have to deal with the dozens of annoying php image processing functions!
Another powerful PHP image thumbnail class: phpThumb can not only scale the image, but also convert the image into different formats for output (for example, the GIF image is output as PNG ), its special features include colors and special effects. Official website: http://phpthumb.sourceforge.net/you can simply copy the following file:
- 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
- Adjust the path to phpThumb according to where you place the phpThumb files.
In fact, phpThumb is more powerful than I previously imagined. below I will list some other useful parameters: Src: Address of the target image w: width of the output image h: height of the output image (if not specified, the image will be scaled proportionally according to the w parameter) q: If the output is in JPG format, the output quality bg can be defined as the background of the output (if needed) sw, sh, sx, sy: local output, width and height, start position f: output format, it can be jpeg, png, gif, or icosfn: output a fltr []: filter in gif animation, which has many effects, including sharpening, blurring, turning, watermarking, border, photo masking, and color adjustment |