首页 > 解决方案 > GD文字大小不变

问题描述

我编写了使用 GD 将文本添加到图像中的代码;它确实有效,但大小不会无缘无故地改变。

这是我的代码:

$image = imagecreatefromjpeg(path);

$text_number = '5101';

$font_size = 20;

$font_color = imagecolorallocate($image,255,255,255);

imagestring($image,$font_size,380,240,$text_number,$font_color);

imagejpeg($image,path to save , 100);

我试图改变$font_size,它不起作用

没有任何工作

谢谢 。

标签: phpgd

解决方案


我认为 20 对于图像字符串的参数来说太大了。

它定义为

bool imagestring ( resource $image , int $font , int $x , int $y , string $string , int $color )

$font 的最大值为 5,只要您没有加载自己的字体。

http://php.net/manual/de/function.imagestring.php


推荐阅读