Laravel 图片添加水印

和这个配合使用

Laravel + ThinkPhP 海报生成_laravel 制作海报-优快云博客

代码

//水印
$x_length = $imageInfo[0];
$y_length = $imageInfo[1];
        
$color = imagecolorallocatealpha($posterImage, 255, 255, 255, 70); // 增加透明度参数alpha

$font_size = 40; //字体大小
$angle = -45; //水印文本旋转度
$water_h = 300;//水印高度
$water_w = 300;//水印宽度

$water_text = '水印文本';//水印文本

for ($x = 0; $x < $x_length; $x += $water_w) {
    for ($y = 0; $y < $y_length; $y += $water_h) {
        imagettftext($posterImage, $font_size, $angle, $x, $y, $color, $fontFile, $water_text);
    }
}
        
imagecolortransparent($posterImage, $color); // 将 $color 颜色设置为透明颜色

完毕

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值