Phpthumb image processing examples, such as the generation of thumbnails, image resizing, image interception, image watermark, picture rotation.
(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.
In the site construction process, the need to deal with the picture of the place many, with the PHP picture function processing pictures, very cumbersome.
And very difficult for beginners to master. Now we can use the Phpthumb class library to deal with the picture, including, image resizing, image interception, image plus watermark, image rotation and so on.
Example:
<?PHP//loading class library filesrequire_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://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);//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 ');
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, effects, etc.
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. Rounded corner thumbnail of an image, simply use the IMG tag of HTML with SRC as<imgsrc= "Phpthumb.php?src=test.jpg&w=200&h=150&fltr[]=ric|20|20&f=png"/>Adjust the path to Phpthumb according to where you place the Phpthumb files.<HTML> <Head></Head> <Body> <imgsrc= "phpthumb/phpthumb.php?src=". /images/test.jpg&w=400&fltr[]=fram|3|2| cc9966|333333| CCCCCC "alt=""> </Body> </HTML>
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.
Original address: http://www.jbxue.com/article/php/20250.html