In the Web application is often used to generate pictures this function, in PHP tutorial to create a picture needs GD library support to create graphics, with this graphical function, we can easily generate thumbnails, verification code, image watermark and so on.
In PHP to install the GD library in order to run the Create image function, as follows, in the win system, find php.ini
Extension=php_gd2.dll in front of the ";" Go, re-start Apache is OK.
Now let's look at an example
PHP's GD library can generate a variety of image files, such as GIF,PNG,JPG,WBMP,XPM, and then look at a square-generated file.
$height = 300;
$width = 300;
Create a background map
$im = Imagecreatetruecolor ($width, $height);
assigning colors
$white = Imagecolorallocate ($im, 255, 255, 255);
$blue = imagecolorallocate ($im, 0, 0, 64);
Draw Color to Image
Imagefill ($im, 0, 0, $blue);
Draw string: hello,php
Imagestring ($im, ten, +, +, ' hello,php ', $white);
Output image, define Header
Header (' content-type:image/png ');
Send an image to a browser
Imagepng ($im);
Clear Resources
Imagedestroy ($im);
?>
View results as long as you browse the PHP file, if you want the image to call
Example two, creating a picture using basic functions Imagecreate ()
resource imagescreate (int x,inty)
Imagedestroy is the amount of memory space that the picture occupies
int Ingaedestroy (image)
Imagecopy ()
int imagecopy (dst_im,sr_im,int x,int y,int x,int y,)
1 2 3 4
http://www.bkjia.com/PHPjc/633047.html www.bkjia.com true http://www.bkjia.com/PHPjc/633047.html techarticle in the Web application is often used to generate pictures this feature, in PHP tutorial to create a picture needs GD library support to create graphics, with this graphical function, we can easily generate ...