thinkphp 添加图片 文字 水印生成带二维码的小程序推广海报
$image = new \Think\Image();
$bgm='./Public/haibao.png'; //背景图
$poster="./Public/poster/$gid.jpg"; //商品水印图位置
$img=explode('/',$list['image']);
$goods="/mnt/data/wwwroot/bzl/Uploads/{$img['4']}/{$img['5']}";
$baocun="./Public/thumbnail/$gid.jpg";//商品缩略图位置
$image->open($goods)->thumb(460, 460,\Think\Image::IMAGE_THUMB_CENTER)->save($baocun); //商品缩略图
//$image->open($bgm)->water($thumb,\Think\Image::IMAGE_WATER_NORTH,100)->save($poster);
$image->open($bgm)->water($baocun,\Think\Image::IMAGE_WATER_NORTH,100)->save($poster);//商品添加到背景图水印
$qrcode=$this->shopqrcode($_GET['uid']);
$qr=explode('/',$qrcode);
//$qr=strripos($qrcode,'/');
$end = end($qr);
//$qrcodeimg="/mnt/data/wwwroot/bzl/Qrcode/watermark/$end";
//$qrcodeimg="/mnt/data/wwwroot/bzl/Qrcode/$uid.png"; //二维码
$qrcodeimg="/mnt/data/wwwroot/bzl/Qrcode/$end";
//$qrcodeimg="https://".$_SERVER[SERVER_NAME]."/Qrcode/$id".".png";//返回二维码
$sulvtu="./Public/thumbnail/code-"."$gid.jpg";//商品缩略图位置
$image->open($qrcodeimg)->thumb(200, 200,\Think\Image::IMAGE_THUMB_CENTER)->save($sulvtu); //商品缩略图
$code="./Public/code/$gid.png"; //二维码水印
$wz=array(130,535);//二维码水印位置
$image->open($poster)->water($sulvtu,$wz,100)->save($code);//二维码添加到背景图水印
$fonts="./msyh.ttf";
$img="./Public/img/$type.$gid.jpg";//最终的海报
$prceiwz=array(30,485);//价格水印位置
$titlewz=array(20,510);//价格水印位置
$res=$image->open($code)->text($list['title'],$fonts,12,'#000000',$titlewz,0,0)->text($list['price'],$fonts,14,'#FF0000',$prceiwz,0,0)->save($img);