Php 在GD库不工作的情况下将文本转换为图像
我是PHP新手,一直在关注youtube上的一个小教程 它将文本转换为图像 但是在遵循代码之后。。不幸的是,我得到的只是一个灰色背景上的小黑匣子 这是我的密码Php 在GD库不工作的情况下将文本转换为图像,php,Php,我是PHP新手,一直在关注youtube上的一个小教程 它将文本转换为图像 但是在遵循代码之后。。不幸的是,我得到的只是一个灰色背景上的小黑匣子 这是我的密码 <?php header("Content-type: image/jpeg"); $email ="example@example.com"; $email_length =strlen($email); $font_size =4; $image_height = ImageFontHeight($font_size);
<?php
header("Content-type: image/jpeg");
$email ="example@example.com";
$email_length =strlen($email);
$font_size =4;
$image_height = ImageFontHeight($font_size);
$image_width = ImageFontWidth($font_size) * $email_length;
$image = imagecreate($image_width,$image_height);
imagecolorallocate($image,255,255,255);
$font_color = imagecolorallocate($image,0,0,0);
imagestring($image,$font_size,0,0,$email,$font_color);
imagejpeg($image);
?>
请注意,我不是试图在这里用gd库对图像进行水印,而是将文本转换为图像
任何帮助都将不胜感激。谢谢我使用wamp服务器时,此代码对我很有效。您使用wamp服务器了吗?如果不是的话,我缺少什么?我在几个平台上测试了它,得到了一个152x16像素的图形,白色背景上有黑色文本。我不知道为什么在灰色背景上有一个小黑匣子。phpinfo()为PHP版本和GD提供了什么?GD设置以及我在wamp服务器上看到的内容