当前位置: 移动技术网 > IT编程>软件设计>面向对象 > TP中的图片水印

TP中的图片水印

2018年12月18日  | 移动技术网IT编程  | 我要评论
         $img_dir = root_path . 'public/upload/card/' . $data['jt_id'];  //创建合成图片存放位置
      //自动创建文件夹 if (!file_exists($img_dir)) { mkdir($img_dir, 0755, true); }
if($data){ $tg_price = $data['tg_price']; //原价 $re_price = '零售价¥'.$data['re_price']; //实际售价 $goods_pic = $data['goods_pic'];//商品图片 if(strlen($data['createtime'])>14){ $endtime = ':'.' '.(substr($data['createtime'],-15)); }else{ $endtime =':'.' '.$data['createtime'];//结束时间 } } //创建水印图片存放位置 $pic_path = root_path . 'public/upload/card/' . $data['jt_id'].'/'.$data['jt_id'].'.png'; //获取到图片路径 $img = file_get_contents($goods_pic); $photo = file_put_contents($pic_path,$img); //将图片放入到指定的目录下 //将图片写入文件 if($photo){ //生成缩略图 $image = image::open($pic_path); $image->thumb(328,158)->save($pic_path); //打开要处理的图片 $pic = image::open('./static/img/tuangou.png'); //水印图片 $xy_pic = [52,65]; $pic->water($pic_path,$xy_pic)->save($img_dir.'/water.png'); //团购价 $xy_price = [92,226]; $pic->text($tg_price,'./static/img/hatten_0.ttf',50,'#f51b51',$xy_price )->save($img_dir.'/water.png'); //零售价 $xy_re_price = array(215,240); $pic->text($re_price,'./static/img/msyh.ttf',17,'#999999',$xy_re_price)->save($img_dir.'/water.png'); //原价的中划线 $xy_unline2 = [214,245]; $pic->text('______________','./static/img/msyh.ttf',18,'#999999',$xy_unline2)->save($img_dir.'/water.png'); //结束时间 $xy_endtime = array(164,310); $pic->text($endtime,'./static/img/msyhbd(1).ttf',21,'#ffffff',$xy_endtime)->save($img_dir.'/water.png'); //输出结果 $url_card = config('website').'/upload/card/'.$data['jt_id'].'/water.png'; }

 

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网