Home > Backend Development > PHP Tutorial > Use of GD library

Use of GD library

WBOY
Release: 2016-07-29 09:06:38
Original
1035 people have browsed it

Create a new canvas and create a true-color blank picture through the imagecreatetruecolor function

$img = imagecreatetruecolor(100,100);

For the color used by the brush, it needs to be allocated through the imagecolorallocate function, and the RGB color value is set through parameters To determine the color of the brush

$red = imagecolorallocate($img, 0xFF, 0x00, 0x00);

Call the line segment function imageline to draw the line, and finally get the line by specifying the starting point and end point.

imageline($img, 0,0,100,100,$red);

Image output through header, imagepng

header("content-type: image/png");

imagepng($img);

Call imagedestroy to release the memory occupied by the image

imagedestroy($img);

Save the drawn image to the file by specifying the file name through the imagepng function

imagepng($image,'line.png');

The above has introduced the use of the GD library, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template