thinkphp 添加图片文字水印生成带二维码的推广海报

2022-04-23 09:54:43 浏览数 (1)

代码语言:javascript复制
<?php
$image = new ThinkImage();
$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,ThinkImage::IMAGE_THUMB_CENTER)->save($baocun);//缩略图
//$image->open($bgm)->water($thumb,ThinkImage::IMAGE_WATER_NORTH,100)->save($poster);
$image->open($bgm)->water($baocun,ThinkImage::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,ThinkImage::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);

?>

0 人点赞