$intR = isset($arrOpt['r']) ? $arrOpt['r'] : 0;
$intG = isset($arrOpt['g']) ? $arrOpt['g'] : 0;
$intB = isset($arrOpt['b']) ? $arrOpt['b'] : 0;
$intX = isset($arrOpt['x']) ? $arrOpt['x'] : 24;
$intY = isset($arrOpt['y']) ? $arrOpt['y'] : 24;
$intSize = isset($arrOpt['fontsize']) ? $arrOpt['fontsize'] : 14;
$intAngle = isset($arrOpt['angle']) ? $arrOpt['angle'] : 0;
$strSave = isset($arrOpt['savepath']) ? $arrOpt['savepath'] : false;
$strFont = isset($arrOpt['ttf']) ? $arrOpt['ttf'] : '/simsun.ttc';***字体库,可以去自己电脑下载
$date=date('Y-m-d H:i',time());
$img="https://".$_SERVER['HTTP_HOST'].(图片路径);
$imageInfo = getimagesize($img);
$base64 = "" . chunk_split(base64_encode(file_get_contents($img)));
$data = base64_decode($base64);
$im = imagecreatefromstring($data);
$color = imagecolorallocate($im, $intR, $intG, $intB);
$strText=‘添加文字内容’;
imagettftext($im, $intSize, $intAngle, 24, 24, $color, $strFont, $strText);
$zhui=explode('.', (图片路径));****截取尾部后缀
$lujing='htsj/'.date('ymd',time());****保存路径
if(!is_dir($lujing)){
mkdir(iconv("UTF-8", "GBK", $lujing),0777,true);
}
$again=$lujing."/".time().".".$zhui[1];****添加数据库路径
imagepng($im,$again);
return $again;