Home  >  Article  >  Backend Development  >  PHP drawing examples, drawing examples_PHP tutorial

PHP drawing examples, drawing examples_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:15:061118browse

php drawing example, drawing example

The example in this article describes how to draw pictures in PHP. Share it with everyone for your reference. The specific implementation method is as follows:

Copy code The code is as follows:
// 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";
//Generating big snowflakes is actually calling imagettftext() to output the * sign
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, 0);
imagettftext($img, 12, 0, $imgWidth - 50, $imgHeight - 20, $black_color, $font_file, "PHP Drawing");
imagepng($img);
imagedestroy($img);
?>

The running effect of this example is shown in the figure below

For more information, please refer to:
http://www.php.net/manual/zh/refs.utilspec.image.php

I hope this article will be helpful to everyone’s PHP programming design.

PHP cannot implement drawing function.

Put the header first and try again. If not, please report a bug.
header("Content-Type:image/gif");
$img=imagecreatetruecolor(50,50);

PHP drawing problem, urgent

1) First check that your PHP does not support the GD library. If it is a windows system,
just remove the semicolon in front of extension=php_gd2.dll in php.ini.
If it is a Linux system, please check the PHP reference manual for the installation instructions of the GD library

2) The code example is as follows:

// Create a 520* 300 picture,
$im = imagecreatetruecolor(520, 300);
imagefilledrectangle($im, 0, 0, 520, 300, 0xFFFFFF);
imageline($im,10,270,510,270,0x000000);
......

// Save the image to file and free memory
imagepng($im, 'photo_stamp.png');
imagedestroy($im);
?>
3) Just draw other systems in sequence.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/906669.htmlTechArticlephp drawing examples, drawing examples This article describes the php drawing method. Share it with everyone for your reference. The specific implementation method is as follows: Copy the code The code is as follows: php // by MoreWindo...
Statement:
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