使用php写的
$myImage=imagecreate(640,1008); //创建一个画布
$jpglg="http://xxx.xxx.cn/images/kailangpai.png"; //这里的图片一定是png-24 如果不是加字的时候颜色就会不一致!
$myImage=imagecreatefrompng($jpglg);//引入一张图片作为背景
$white=imagecolorallocate($myImage,255,255,255);//定义一个颜色以后用
$black=imagecolorallocate($myImage,0,0,0);//定义一个颜色以后用
$hese=imagecolorallocate($myImage,139,0,0);//定义一个颜色以后用
//$red=imagecolorallocate($myImage, 255, 0, 0);//定义一个颜色以后用
//$green=imagecolorallocate($myImage, 0, 255, 0);//定义一个颜色以后用
//$blue=imagecolorallocate($myImage, 0, 0, 255);//定义一个颜色以后用
$wenhe=imagecolorallocate($myImage,255,165,0);//定义一个颜色以后用
$gaoleng=imagecolorallocate($myImage,0,0,205);//定义一个颜色以后用
$fendou=imagecolorallocate($myImage,178,34,34);//定义一个颜色以后用
imagettftext($myImage,21,0,258,549,$hese,"fonts/klt.ttf",$z); //插入文字 21是字体大小具体的去看函数说明不过多解释
$imgyum=time().$rowtm['id'].".gif";//生成图片的路径
imagegif($myImage,$imgyum);//生成图片
imagedestroy($myImage);//删除创建的临时缓存我是这么理解的
问题来了想合成头像图片怎么办 找了半天找不到办法只能先生成一张再合成头像了
$dst_path = 'http://xxx.xxx.cn/'.$imgyum;//目标图片
$src_path = 'http://xxx.xxx.cn/tx/'.$rowtm['tx'];//水印图片
//创建图片的实例
$dst = imagecreatefromstring(file_get_contents($dst_path));
$src = imagecreatefromstring(file_get_contents($src_path));
//获取水印图片的宽高
list($src_w, $src_h) = getimagesize($src_path);
//将水印图片复制到目标图片上,最后个参数50是设置透明度,这里实现半透明效果,两个20是控制水印坐标位置
imagecopymerge($dst, $src, 256,242,0,0,$src_w,$src_h, 100);
//如果水印图片本身带透明色,则使用imagecopy方法
//imagecopy($dst, $src, 10, 10, 0, 0, $src_w, $src_h);
//输出图片
$imgyumtt=time().$rowtm['id']."x.gif";//生成图片的路径
imagegif($dst,$imgyumtt);
imagedestroy($dst);//销毁
imagedestroy($src);//销毁
如果有其他见解可以给我提一下
实例下载地址 https://download.youkuaiyun.com/download/woshi66a/10360269