One problem I can see straight away is that the $imagetobewatermark
variable starts off as a string, then becomes a new blank image object (not an existing image), and when you subsequently create the mark
image object, it's not going to work because $imagetobewatermark
is no longer a string.
Try:
$imagetobewatermark=imagecreatefrompng("images/muggu.png");
$watermarktext="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);
EDIT:
I failed to notice a typo in your text variable $wartermarktext
, which should be $watermarktext
.
Correct this and it should work.