[英]Why isn't the PHP imagettftext function working in this case?
誰能告訴我為什么我要創建驗證碼時不能使用imagettftext函數嗎? 它可以很好地處理圖像字符串,但是字體大小很小,所以我必須使用imagettftext ... Wamp是問題嗎? 謝謝你的時間!
PHP代碼(到目前為止):
<?php
session_start();
header("Content-Type: image/png");
$text = $_SESSION['secure'];
$font_size = 30;
$image_width = 200;
$image_height = 40;
$image = imagecreate($image_width, $image_height);
imagecolorallocate($image, 255, 255, 255);
$text_color = imagecolorallocate($image, 0, 0, 0);
imagettftext($image, $font_size, 0, 15, 30, $text_color, 'arial.ttf', $text);
imagepng($image);
?>
Index.php:
<?php
session_start();
$_SESSION['secure'] = rand(1000,9999);
?>
<img src="createanimage.php" />
從您提供的少量信息來看,代碼最初對我不起作用,我將字體路徑從arial.ttf
更改為./arial.ttf
。 有效!
您的代碼的精確副本: http : //tekinozbek.net/so_imagettftext.php
當心一些垃圾郵件發送者使用圖像分析來識別文本路徑並確定CAPTCHA圖像! 我肯定會建議您使用諸如reCAPTCHA之類的東西來更好地防止垃圾郵件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.