php 一段GD库使用代码,主要是练习GD库的使用
$img = imagecreatetruecolor(200,200);
$white = imagecolorallocate($img,255,255,255);
$black = imagecolorallocate($img,0,0,0);
$red = imagecolorallocate($img,255,0,0);
$alphaRed = imagecolorclosestalpha($img,255,0,0,50);
imagefill($img,0,0,$white);
imagearc($img,100,100,150,150,0,360,$black);
imageline($img,20,180,120,120,$black);
imagefilledrectangle($img,30,30,70,70,$alphaRed);
$string = "I like PHP!";
imagechar($img,5,70,50,$string,$black);
imagecharup($img,3,120,50,$string,$black);
imagestring($img,5,70,150,$string,$black);
imagestringup($img,3,120,150,$string,$black);
ob_start();
imagepng($img);
$image_data = ob_get_clean();
$src = base64_encode($image_data);
imagedestroy($img);
ob_end_clean();