php 生成jpg文件,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);

?>

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值