php绘图

首先编辑php.ini,放开extension=php_gd2.dll。

<?php

header("Content-type:image/png");//png|gif|jpeg

$im = ImageCreateTrueColor(600, 400);

$green = ImageColorAllocate($im, 50, 203, 43);

ImageFill($im, 0, 0, $green);

ImageLine($im, 10, 20, 45, 80, $green);

ImagePNG($im);

ImageDestroy($im);

?>

注意php函数大小写不敏感,也可以这样

<?php

$im = imagecreatetruecolor(520, 300);

imagefilledrectangle($im, 0, 0, 520, 300, 0xffffff);

imageline($im, 10, 270, 510, 270, 0x000000);

//画更多形状需参考php文档

imagepng($im, "photo.png");

imagedestroy($im);

?>

posted @ 2014-10-31 16:28  feilv  阅读(202)  评论(0编辑  收藏  举报