Phpthumb Picture Processing Instance _php instance

Source: Internet
Author: User

Download address (GITHUB.COM/MASTEREXPLODER/PHPTHUMB).
Note that this class library has a duplicate name called Phpthumb, but the difference between the case, so look for documents to be sure to pay attention.
In the site construction process, the need to deal with pictures of many places, with PHP picture function processing pictures, very cumbersome. And it is very difficult for beginners to master. Now we can use the Phpthumb class library to handle the picture, including, picture size adjustment, picture interception, picture watermark, picture rotation and so on function.

Use Demo:

Copy Code code as follows:

Loading class library files
Require_once ' path/to/thumblib.inc.php ';

Instantiate the class library, and the address of the image you want to process can be either a network address or a local address
$thumb = phpthumbfactory::create (' http://www.jb51.net/');

Reduce the picture to a maximum width of 100px or 100px, and when only one parameter is entered, it is the widest size.
$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 image, note that this is intercepted, the excess part of the direct cut off, not forced to change the size.
$thumb->adaptiveresize (175, 175);

From the center of the picture, intercept the 200px * 100px picture.
$thumb->cropfromcenter (200, 100);

Screenshot, the first two parameters are required to solve the picture's upper right corner of the coordinate x,y. The following two parameters are needed to solve the picture wide and high.
$thumb->crop (100, 100, 300, 200);

Reverse the picture 180 degrees clockwise
$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 do not introduce, if you are also in the development of PHP site needs to deal with the picture may wish to read this class library documents, to ensure that you deal with the picture is very simple, no longer with the more than 10 annoying PHP image processing functions to deal with!


Another powerful php picture thumbnail class: Phpthumb

In addition to scaling pictures, the class can also convert pictures into different format output (for example, the image in GIF format is exported to PNG format), and its features include color, special effects, etc.
Official website: http://phpthumb.sourceforge.net/

Generally, only the following files are required:
[Code] We ' ll be using Phpthumb, the open source PHP script to generate thumbnails on the fly.
Download and extract Phpthumb to somewhere in your folder. Now to use a rounded corner thumbnail of "an", simply use the IMG tag's HTML with SRC as

Adjust the path to Phpthumb according to where the Phpthumb files.



<body>

</body>


In fact, Phpthumb's function is more powerful than I thought, and here's a list of some of his other useful parameters:
SRC: Address of the target picture
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 ratio)
Q: If the output is in JPG format, it can specify its output quality
BG: Background When output (if required)
SW, SH, SX, sy: Partial output, wide and high, starting position
F: Output format, can be JPEG, PNG, GIF, ICO
SFN: Output A frame in a GIF animation
Fltr[]: Filters, can have many effects, including sharpening, Blur, spin flip, watermark, border, shading, 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.