PHP drawings to load external images of the method,
This article describes the method of loading external images in PHP drawings. Share to everyone for your reference. The implementation method is as follows:
In the actual application, is the common watermark function.
Copy the Code code as follows: <?php
1. Create a canvas
$im = Imagecreatetruecolor (300,200);//Create a new true color image, the default background is black, return the image identifier. There is also a function imagecreate has not been recommended for use.
2. Loading external images
$im _new = imagecreatefromjpeg ("baidu.jpg");//return image identifier
$im _new_info = getimagesize ("baidu.jpg");//Gets the image size and returns an array. The function does not need to use the GD library.
/*----
3. Copy the loaded picture to the canvas
Parameter description:
$im: Needless to say, it means the canvas;
$im _new: Source images, which are images loaded from the outside
(30,30): Place the loaded image in the canvas, in the upper-left corner
(0,0): Represents the loaded picture, starting from where. (0,0) Indicates the beginning of the upper-left corner, or only a portion of the image can be loaded.
(*,*): in *, can be the original picture width and height, can also be less than the width of the high, only part of the interception, with the above coordinates, to indicate the part of the interception
******/
Imagecopy ($im, $im _new,30,30,0,0, $im _new_info[0], $im _new_info[1]);//Returns a Boolean value
3. Output image
Header ("Content-type:image/png");
Imagepng ($im);//output to page. If there is a second argument [, $filename], the image is saved
4. Destroy the image and release the memory
Imagedestroy ($im);
?>
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/947209.html www.bkjia.com true http://www.bkjia.com/PHPjc/947209.html techarticle PHP Drawing of the method of loading external images, this article describes the PHP drawing of the method of loading external images. Share to everyone for your reference. The concrete implementation method is as follows: In the practical application ...