-
-
//1. Create canvas - $im = imagecreatetruecolor(300,200);//Create a new true color image, the default background is black, and return the image identifier. There is also a function imagecreate that has been deprecated.
//2. Load external images
- $im_new = imagecreatefromjpeg("baidu.jpg");//Return the image identifier
- $im_new_info = getimagesize("baidu.jpg");/ /Get the image size and return an array. This function does not require the use of the gd library.
- /*----
- ****3. Copy the loaded image to the canvas
- ****Parameter description:
- $im: Needless to say, it refers to the canvas;
- $im_new: source image, That is, the image loaded in from the outside
- (30,30): Place the loaded image in the position of the canvas. The upper left corner
- (0,0): Indicates where the loaded image starts. (0,0) represents the starting point of the upper left corner. You can also load only a part of the image. (*,*): represented by *, it can be the width and height of the original image, or it can be smaller than the width and height. Only a part of the image is intercepted, and it is the same as the above Used together with coordinates, it represents the intercepted part
- ******/bbs.it-home.org
- imagecopy($im,$im_new,30,30,0,0,$im_new_info[0],$im_new_info[1 ]);//Return Boolean value
//3. Output image
- header("content-type: image/png");
- imagepng($im);//Output to page . If there is a second parameter [,$filename], it means saving the image
//4. Destroy the image and release the memory
- imagedestroy($im);
- ?>
-
-
Copy code
|