没有正确渲染我的图像
Not rendering my image correctly
我尝试制作一个呈现随机文本的验证码图像(看看我的 $_SESSION["captcha"]
)。
它在我的本地主机上使用 WAMP 完美运行,但在我的网站上它只显示一个透明的 64x20 图像,没有文字,什么都没有。
我之前有一个错误 500,我安装了 php5-gd + 重新启动了 Apache,也许我错过了一些要安装的东西?
我无法访问我的(错误)日志。
这是我的代码:
<?php
session_start();
$_SESSION["captcha"] = mt_rand(100, 999);
$img = imagecreatetruecolor(64, 20);
$font = "Inversionz.otf";
imagealphablending($img, true);
imagesavealpha($img, true);
imagefill($img, 0, 0, 0x7fff0000);
$textcolor = imagecolorallocate($img, 0, 0, 0);
imagettftext($img, 27, 0, 0, 20, $textcolor, $font, $_SESSION["captcha"]);
header("Content-type:image/png");
imagepng($img);
imagedestroy($img);
?>
我的字体(Inversionz.otf)已上传。
好吧,你让我去本地找到那个字体 运行。 :)
我遇到了与您相同的错误,直到...
请击鼓。
我在路径中添加了./。
$font = "./Inversionz.otf";
我尝试制作一个呈现随机文本的验证码图像(看看我的 $_SESSION["captcha"]
)。
它在我的本地主机上使用 WAMP 完美运行,但在我的网站上它只显示一个透明的 64x20 图像,没有文字,什么都没有。
我之前有一个错误 500,我安装了 php5-gd + 重新启动了 Apache,也许我错过了一些要安装的东西?
我无法访问我的(错误)日志。
这是我的代码:
<?php
session_start();
$_SESSION["captcha"] = mt_rand(100, 999);
$img = imagecreatetruecolor(64, 20);
$font = "Inversionz.otf";
imagealphablending($img, true);
imagesavealpha($img, true);
imagefill($img, 0, 0, 0x7fff0000);
$textcolor = imagecolorallocate($img, 0, 0, 0);
imagettftext($img, 27, 0, 0, 20, $textcolor, $font, $_SESSION["captcha"]);
header("Content-type:image/png");
imagepng($img);
imagedestroy($img);
?>
我的字体(Inversionz.otf)已上传。
好吧,你让我去本地找到那个字体 运行。 :)
我遇到了与您相同的错误,直到...
请击鼓。
我在路径中添加了./。
$font = "./Inversionz.otf";