PHP drawing instances, drawing examples
This article describes the method of drawing PHP. Share to everyone for your reference. The implementation method is as follows:
Copy the Code code as follows: <?php
by morewindows
$imgWidth = 600;
$imgHeight = 400;
$img = Imagecreatetruecolor ($imgWidth, $imgHeight);
Imagefill ($img, 0, 0, imagecolorallocate ($img, 240, 240, 240));//Set background
$snowflake _size = 30;
$font _file = "C:\\windows\\fonts\\simhei.ttf";
Generating a big snowflake is actually calling the Imagettftext () output * number
for ($i =1; $i <=400; $i + +)
{
$font _color = imagecolorallocate ($img, Mt_rand (100,200), Mt_rand (100,200), Mt_rand (100,200));
Imagettftext ($img, $snowflake _size, Mt_rand (0, Mt_rand), Mt_rand (0, $imgWidth), _color (0, $imgHeight), $font, $font _ File, "-");
}
Watermark Text
$black _color = imagecolorallocate ($img, 0, 0, 0);
Imagettftext ($img, 0, $imgWidth -50, $imgHeight -20, $black _color, $font _file, "PHP drawing");
Imagepng ($IMG);
Imagedestroy ($IMG);
?>
This example works as shown in the
For more information, please refer to:
http://www.php.net/manual/zh/refs.utilspec.image.php
I hope this article is helpful to everyone's PHP programming.
PHP can not be used to achieve drawing
First put the header on the front and try again. If not, please return the error.
Header ("Content-type:image/gif");
$img =imagecreatetruecolor (50,50);
PHP drawing problems, urgent
1) first check your PHP and do not start the GD library support. If it is a Windows system,
Extension=php_gd2.dll the semicolon in front of the php.ini directly on the line.
If it is a Linux system, please refer to the PHP reference manual installation instructions for the GD library
2) code examples are as follows:
!--? php
//Create a 520*300 picture,
$im = imagecreate TrueColor (520, 300);
Imagefilledrectangle ($im, 0, 0, 520, 0xFFFFFF);
Imageline ($im, 10,270,510,270,0x000000);
...
//Save the image to file and free memory
Imagepng ($im, ' photo_stamp.png ');
Imagedestroy ($im);
? >< br> 3) Draw other systems in turn.
http://www.bkjia.com/PHPjc/906669.html www.bkjia.com true http://www.bkjia.com/PHPjc/906669.html techarticle Examples of PHP drawing, drawing Examples This article describes the method of PHP drawing. Share to everyone for your reference. The implementation is as follows: Copy code code as follows: PHP//by Morewindo ...