🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
一、png图片生成 public function entryOp() { $img = 'http://newmall.yewugou.com/ylfapporderform/images/test.png'; list($width, $height) = @getimagesize($img); $image = imagecreatefrompng($img);//创建图片模板 imagesavealpha($image,true);//保留通道信息 $thumb = imagecreatetruecolor($width,$height);//创建真彩图 //设置字体开始 $black = imagecolorallocate($image, 98, 52, 11);//拾色器 $font_file = $_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR.'mobile'.DIRECTORY_SEPARATOR.'fonts'.DIRECTORY_SEPARATOR.'msyh.ttf'; imagefttext($image, 25, 0, 980, 125, $black, $font_file, '2016年11月05日'); imagefttext($image, 25, 0, 980, 165, $black, $font_file, '2017年05月05日'); imagefttext($image, 25, 0, 630, 295, $black, $font_file, '梦儿'); imagefttext($image, 25, 0, 630, 390, $black, $font_file, '18005076960'); imagefttext($image, 25, 0, 630, 480, $black, $font_file, '18005076960'); imagefttext($image, 25, 0, 630, 570, $black, $font_file, '伐木累'); $color = imagecolorallocate($image, 255, 84, 31); imagefttext($image, 40, 0, 530, 690, $color, $font_file, '动作'); //设置字体结束 imagealphablending($thumb,false); imagesavealpha($thumb,true); imagecopyresampled($thumb,$image,0,0,0,0,$width,$height,$width,$height); header("content-type: image/png"); imagepng($thumb); imagedestroy($image); }