The use of PHP-GD Library--play with The Fortune Circle PHP (2)

Source: Internet
Author: User

To continue with the previous article, we proceeded to study the GD library. This article studies the processing of images in GD library, using examples for the rotation of images and the addition of watermarks.

Let's get to know the functions we're going to use.

  Resource imagerotate ( resource $image , float $angle , int $bgd_color [, int $ignore_transparent = 0])

< Span class= "type" >< Span class= "Methodparam" > < Span class= "type" > imagerotate  src_im   image with a given  angle   angular rotation. bgd_color   Specifies the color of the part that is not covered after rotation. The center of the rotation is the center of the image, and the rotated image is scaled down to fit the target image-the edges are not clipped.

There are a few points to note that this function is rotated counterclockwise. Rotation is a very simple thing to do with this function, the code is as follows.

<?PHP//It's just a random function. To illustrate the usage of rotation and the use of several points that need to be noticed//this is used to rotate the stored picture to an angle and overwrite the source file    functionFlip$filename,$degress){     //Some of the pictures may be too large, so you need to set the script maximum memory     Ini_set(' Memory_limit ', ' 256M '); //This function is to obtain image information, similar to the less commonly used images will be in the final summary of the unified introduction        $data= @getimagesize($filename); if($data==false){            return false; }        $file _type=Explode(‘/‘,$data[' MIME ']);//Create an image based on the store file extension resource        if($file _type[1]== ' PNG '){            $src _f= @imagecreatefrompng ($filename); }Else{            $src _f= @imagecreatefromjpeg ($filename); }        if($src _f==""){            return false; }//rotate and overwrite the rotated resource into the original file        $rotate= @imagerotate ($src _f,$degrees, 0); if($file _type[1]== ' PNG ') {imagepng ($rotate,$filename); }Else{imagejpeg ($rotate,$filename); }//Destroying Resources@imagedestroy ($src _f); @imagedestroy ($rotate); return true; }?>

boolImagecopymerge (Resource$dst_im,resource  $SRC _im  ,  int  $DST _x  , int  $DST _y  , int  $SRC _x ,  int  $SRC _y  , int  $SRC _w  , int  $SRC _h  ,  int  $pct  )

src_imcopies the coordinates in the image from, to the width of, the height to the position of the coordinates in the src_x src_y  src_w src_h dst_im image dst_x dst_y . The two images will pct determine the degree of consolidation based on their values ranging from 0 to 100. When pct = 0 o'clock, actually did nothing, when 100 for the palette image this function and imagecopy () exactly the same, it is the true color image to achieve alpha transparency.

Eat soon, after dinner and then to the whole ha ~ ~ ~

The use of PHP-GD Library--play with The Fortune Circle PHP (2)

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.