Php drawing instance and drawing instance
This article describes the php plotting method. Share it with you for your reference. The specific implementation method is as follows:
Copy codeThe Code is as follows: <? Php
// By MoreWindows
$ ImgWidth = 600;
$ ImgHeight = 400;
$ Img = imagecreatetruecolor ($ imgWidth, $ imgHeight );
Imagefill ($ img, 0, 0, imagecolorallocate ($ img, 240,240,240); // set the background color
$ Snowflake_size = 30;
$ Font_file = "c: \ WINDOWS \ Fonts \ simhei. ttf ";
// Generate a big snowflake, which is actually calling imagettftext () to output the * 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,180), mt_rand (0, $ imgWidth), mt_rand (0, $ imgHeight), $ font_color, $ font_file, "□ ");
}
// Watermark text
$ Black_color = imagecolorallocate ($ img, 0, 0 );
Imagettftext ($ img, 12, 0, $ imgWidth-50, $ imgHeight-20, $ black_color, $ font_file, "PHP drawing ");
Imagepng ($ img );
Imagedestroy ($ img );
?>
Shows the running effect of this instance.
For more information, see:
Http://www.php.net/manual/zh/refs.utilspec.image.php
I hope this article will help you with PHP programming.
PHP does not support drawing.
Put the header at the beginning and try again. If not, return an error.
<? Php
Header ("Content-Type: image/gif ");
$ Img = imagecreatetruecolor (50, 50 );
PHP drawing problems, urgent
1) Check whether your PHP does not support the GD library. In windows,
Simply remove the semicolon before extension = php_gd2.dll in php. ini.
For linux systems, check the instructions on installing the GD library in the php reference manual.
2) sample code:
<? Php
// Create an image of 520*300,
$ Im = imagecreatetruecolor (520,300 );
Imagefilledrectangle ($ im, 0, 0,520,300, 0 xFFFFFF );
Imageline ($ im, 10,270,510,270, 0x000000 );
......
// Save the image to file and free memory
Imagepng ($ im, 'photo_stamp.png ');
Imagedestroy ($ im );
?>
3) draw other systems in sequence.