【发布时间】:2014-01-20 11:48:25
【问题描述】:
我有一张图片,我正在尝试使用文本为图片添加水印。
我已经完成了代码部分,但没有看到带有水印文本的图像。
下面是代码:
$imagetobewatermark="images/muggu.png";
list($width,$height)=getimagesize($imagetobewatermark);
$imagetobewatermark=imagecreatetruecolor($width,$height);
$mark=imagecreatefrompng($imagetobewatermark);
imagecopy($imagetobewatermark,$mark,0,0,0,0,$width,$height);
$wartermarktext="Muggu";
$font="../font/century gothic.ttf";
$fontsize="15";
$white = imagecolorallocate($imagetobewatermark, 255, 255, 255);
imagettftext($imagetobewatermark, $fontsize, 0, 20, 10, $white, $font, $watermarktext);
header("Content-type:image/png");
imagepng($imagetobewatermark);
imagedestroy($imagetobewatermark);
如果我错了告诉我。
谢谢。
【问题讨论】:
-
你为什么不使用像intervention/image这样的包?
-
啊,打错字了!我更新了我的答案...