和這個配合使用
Laravel + ThinkPhP 海報生成_laravel 制作海報-CSDN博客
代碼
//水印
$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 顏色設置為透明顏色