PHP 生成图片

<?php
/**
 * Created by PhpStorm.
 * User: wangzhen
 * Date: 2018/4/28
 * Time: 10:58
 */
//1.创建画布
$img=imagecreatetruecolor(500,400);
//2.准备颜色
$black=imagecolorallocate($img,0,0,0);
$blue=imagecolorallocate($img,0,0,255);
$white=imagecolorallocate($img,255,255,255);
$green=imagecolorallocate($img,0,255,0);
$red=imagecolorallocate($img,204, 0, 0);
$hui=imagecolorallocate($img,217, 217, 217);
//3.在画布上画图像或文字
imagefill($img,0,0,$black);
//imagefilledellipse($img,253,202.1,200,160,$hui);
$a=250;$b=201;
for($i=0;$i<50;$i++){
    $a+=0.1;
    $b=$b+0.1;
    imagefilledarc($img,$a,$b,200,200,0,360,$hui,IMG_ARC_PIE);
}
imagefilledarc($img,250,200,200,200,0,120,$white,IMG_ARC_PIE);
imagefilledarc($img,250,200,200,200,120,240,$green,IMG_ARC_PIE);
imagefilledarc($img,250,200,200,200,240,360,$blue,IMG_ARC_PIE);

imagettftext($img,15,0,180,200,$red,'../msyhbd.ttf','30%');
imagettftext($img,15,0,260,180,$red,'../msyhbd.ttf','30%');
imagettftext($img,15,0,260,230,$red,'../msyhbd.ttf','30%');
//4.输出图像
header("content-type/jpeg");
imagejpeg($img);

//5.释放画布资源
imagedestroy($img);

?>

猜你喜欢

转载自blog.csdn.net/king2wang/article/details/81284547