在php中的图像上的水印文本中的字体问题

时间:2017-12-27 08:34:40

标签: php text watermark

我在php中的图像上有水印文本的问题 我的代码是

$im='myimage.jepeg'
header ("Content-type: image/jpeg");

$string = "text on image";

$font = 4;

$width = imagefontwidth($font) * strlen($string) ;

$height = imagefontheight($font) ;

$im = imagecreatefromjpeg($im);

$x = imagesx($im) - $width ;

$y = imagesy($im) - $height;

$backgroundColor = imagecolorallocate ($im, 255, 255, 255);

$textColor = imagecolorallocate ($im, 0, 0,0);

imagettftext ($im, $font, $x, $y, $string, $textColor);

imagejpeg($im);

我有更改字体大小但无法正常工作

1 个答案:

答案 0 :(得分:0)

您在脚本中使用的扩展程序jepeg没有。所以替换下面的脚本

$im='myimage.jepeg';

$im='myimage.jpeg';

另外你需要注意分号; php脚本会停止并返回错误,如果错过了将分号放在脚本的末尾。