php多图片和文字合成最终图片
来源:互联网 发布:第一源码网 编辑:程序博客网 时间:2024/05/22 12:08
<?php$id=$_GET['id'];$conn=mysql_connect("localhost","root","root");mysql_select_db("yx",$conn);mysql_query("set names utf8");$sql="select * from pigcms_lottery where id='$id'";$result=mysql_query($sql);$arr=mysql_fetch_assoc($result);//echo $arr['fist'];//echo $arr['second'];//echo $arr['third'];//echo $arr['four'];//echo $arr['five'];//echo $arr['six'];function hc1($content1,$content2,$content3,$content4,$content5,$content7){ /*打开图片*/ //1.配置图片路径 $src = "http://localhost/tpl/Wap/default/common/css/guajiang/images/bb.png";//2.获取图片信息 $info = getimagesize($src); //3.通过编号获取图像类型 $type = image_type_to_extension($info[2],false); //4.在内存中创建和图像类型一样的图像 $fun = "imagecreatefrom".$type; //5.图片复制到内存 $image = $fun($src); $background = imagecolorallocate($image, 255, 255, 255); imagecolortransparent($image, $background);//imagealphablending($image, false);imagesavealpha($image, true);/*操作图片*/ //1.设置字体的路径 $font = "msyh.ttf"; //2.填写水印内容$size=15; //$content1 = ""; //3.设置字体颜色和透明度 $color = imagecolorallocatealpha($image, 255, 255,255,0); //4.写入文字 imagettftext($image, "$size", -45, 325, 80, $color, $font, $content1); //$content2 = ""; //3.设置字体颜色和透明度 $color = imagecolorallocatealpha($image, 255, 255,255,0); //4.写入文字 imagettftext($image, "$size", 90, 40, 250, $color, $font, $content2); //$content3 = ""; //3.设置字体颜色和透明度 $color = imagecolorallocatealpha($image, 255, 255,255,0); //4.写入文字 imagettftext($image,"$size", 130, 112,360, $color, $font, $content3); //$content4 = ""; //3.设置字体颜色和透明度 $color = imagecolorallocatealpha($image, 255, 255,255,0); //4.写入文字 imagettftext($image,"$size", 0, 160, 400, $color, $font, $content4); //$content5 = ""; //3.设置字体颜色和透明度 $color = imagecolorallocatealpha($image, 255, 255,255,0); //4.写入文字 imagettftext($image, "$size", 40, 310, 380, $color, $font, $content5); $content6 = "谢谢参与"; //3.设置字体颜色和透明度 $color = imagecolorallocatealpha($image, 255, 255,255,0); //4.写入文字 imagettftext($image, "$size", 88, 400, 265, $color, $font, $content6); //$content7= ""; //3.设置字体颜色和透明度 $color = imagecolorallocatealpha($image, 255, 255,255,0); //4.写入文字 imagettftext($image,"$size", 0, 185, 40, $color, $font, $content7); $content8 = "谢谢参与"; //3.设置字体颜色和透明度 $color = imagecolorallocatealpha($image, 255, 255,255,0); //4.写入文字 imagettftext($image, "$size", 50, 70, 120, $color, $font, $content8); /*输出图片*/ //浏览器输出 header("Content-type:".$info['mime']); $fun = "image".$type; //$fun($image); //保存图片 $fun($image,'bg_res.'.$type);imagepng($image, "C:\\newbb3.png");//imagejpeg($image, "C:\\newbb.jpg");/*销毁图片*/ imagedestroy($image); }echo hc1($arr['six'],$arr['second'],$arr['third'],$arr['four'],$arr['five'],$arr['fist']);function hc2($qCodePath,$img4,$img5,$img6,$img7,$img9){$bigImgPath = 'C:\\newbb3.png';$img3='http://localhost/tpl/Wap/default/common/css/guajiang/images/zlyc.png';$img8='http://localhost/tpl/Wap/default/common/css/guajiang/images/jxnl.png';$bigImg = imagecreatefromstring(file_get_contents($bigImgPath));$qCodeImg = imagecreatefromstring(file_get_contents($qCodePath));$qCodeImg3= imagecreatefromstring(file_get_contents($img3));$qCodeImg4= imagecreatefromstring(file_get_contents($img4));$qCodeImg5= imagecreatefromstring(file_get_contents($img5));$qCodeImg6= imagecreatefromstring(file_get_contents($img6));$qCodeImg7= imagecreatefromstring(file_get_contents($img7));$qCodeImg8= imagecreatefromstring(file_get_contents($img8));$qCodeImg9= imagecreatefromstring(file_get_contents($img9));$qCodeWidth='60px';$qCodeHight='60px';list($qCodeWidth, $qCodeHight, $qCodeType) = getimagesize($qCodePath);list($qCodeWidth3, $qCodeHight3, $qCodeType) = getimagesize($img3);list($qCodeWidth4, $qCodeHight4, $qCodeType) = getimagesize($img4);list($qCodeWidth5, $qCodeHight5, $qCodeType) = getimagesize($img5);list($qCodeWidth6, $qCodeHight6, $qCodeType) = getimagesize($img6);list($qCodeWidth7, $qCodeHight7, $qCodeType) = getimagesize($img7);list($qCodeWidth8, $qCodeHight8, $qCodeType8) = getimagesize($img8);list($qCodeWidth9, $qCodeHight9, $qCodeType9) = getimagesize($img9);// imagecopymerge使用注解imagecopymerge($bigImg, $qCodeImg, 190, 80, 0, 0, $qCodeWidth, $qCodeHight, 100);imagecopymerge($bigImg, $qCodeImg3, 113, 95, 0, 0, $qCodeWidth3, $qCodeHight3, 100); imagecopymerge($bigImg, $qCodeImg4, 70, 190, 0, 0, $qCodeWidth4, $qCodeHight4, 100); imagecopymerge($bigImg, $qCodeImg5, 90, 280, 0, 0, $qCodeWidth5, $qCodeHight5, 100); imagecopymerge($bigImg, $qCodeImg6, 173, 300, 0, 0, $qCodeWidth6, $qCodeHight6, 100); imagecopymerge($bigImg, $qCodeImg7, 270, 290, 0, 0, $qCodeWidth7, $qCodeHight7, 100);imagecopymerge($bigImg, $qCodeImg8, 300, 200, 0, 0, $qCodeWidth8, $qCodeHight8, 100);imagecopymerge($bigImg, $qCodeImg9, 280, 120, 0, 0, $qCodeWidth9, $qCodeHight9, 100);list($bigWidth, $bigHight, $bigType) = getimagesize($bigImgPath);$background = imagecolorallocate($bigImg, 255, 255, 255); imagecolortransparent($bigImg, $background);imagesavealpha($bigImg, true); switch ($bigType) {case 1: //gifheader('Content-Type:image/gif');imagegif($bigImg);break;case 2: //jpgheader('Content-Type:image/jpg');imagejpeg($bigImg);break;case 3: //jpgheader('Content-Type:image/png');imagepng($bigImg);break;default:# code...break;}imagepng($bigImg, "C:\\nbb.png"); imagedestroy($bigImg);}//echo hc2("http://localhost/tpl/Wap/default/common/css/guajiang/images/hwsh.png","http://localhost/tpl/Wap/default/common/css/guajiang/images/hwsh.png","http://localhost/tpl/Wap/default/common/css/guajiang/images/hwsh.png","http://localhost/tpl/Wap/default/common/css/guajiang/images/hwsh.png","http://localhost/tpl/Wap/default/common/css/guajiang/images/hwsh.png","http://localhost/tpl/Wap/default/common/css/guajiang/images/hwsh.png");echo hc2($arr['bg1'],$arr['bg2'],$arr['bg4'],$arr['bg5'],$arr['bg6'],$arr['bg7']);?>
阅读全文
1 0
- php多图片和文字合成最终图片
- php 图片和文字合成图片技术
- (PHP)图片加文字和图片合成
- PHP合成多图片
- canvas 图片 文字 合成
- PHP合成推广微信推广海报 PHP合成图片 PHP在图片上添加文字 PHP制作图片
- php合成图片
- PHP 图片合成
- iOS图片拼接,图片文字合成总结
- php 两张图片合成
- java合成图片并添加文字
- iOS开发图片合成,多张图片合成一张图片
- PHP水印图片文字
- 【php】文字转图片
- PHP 图片添加水印(文字和图片)
- PHP给图片加文字水印和图片水印
- PHP图片添加文字水印和图片水印
- iOS 图片合成和裁剪
- Java方法中 访问url 下载链接,下载文件
- shell实现进度条
- 【每天一点Linux】shell脚本学习之二——语法
- Android触屏事件和MotionEvent介绍
- 【长沙·签约】中企动力携手郴州市城市规划设计院布局一站式全网门户平台
- php多图片和文字合成最终图片
- 调试的错误就是编程给你最好的东西,因为在每个错误上面都标志着前进的一步
- 常用SQL语句
- Say Goodbye To findViewById
- oracle--left join and 和left join where的区别
- PHP 7中新的Hashtable实现和性能改进
- js使用rsa加密大数据块的java实现
- 使用mybatis在mysql中进行like查询遇到的问题
- 美团CODEM 字串