我正在使用此代碼來創建具有透明背景的文字。在透明背景圖像中的字母邊框是不需要的?
<?php
// Set the content-type
header('Content-Type: image/gif');
// Create the image
$im = imagecreatetruecolor(400, 150);
// Create some colors
$black = imagecolorallocate($im, 0, 0, 0);
$acolor = imagecolorallocate($im, 153, 204, 153);
imagecolortransparent($im, $black);
// The text to draw
$text = 'Testing...';
// Replace path by your own font path
$font = 'arial.ttf';
// Add the text
imagettftext($im, 50, 0, 10, 100, $acolor, $font, $text);
// Using imagegif()
imagegif($im,"img.gif");
imagedestroy($im);
?>
但是這是寫在img.gif文本對字母的邊框一些不需要的顏色(黑色)( 'E,S,N,G')。我怎樣才能完成該顏色啊生成的圖像是
Arial字體下載網站是http://code.google.com/p/ireader/downloads/detail?name=arial.ttf
不完全清楚你的意思:你能提供一個示例圖形來展示問題嗎?另外,我不確定你在這裏要做什麼,但是如果你正在使用這些圖形在你的網站上顯示文本,那麼使用HTML/CSS而不使用圖形可能會更好地實現它。但這取決於你想要做什麼。 – Spudley
@Spudley這個代碼輸出這個圖像寫在'測試'它http://imageshack.us/photo/my-images/851/imgsi.png/在字母'e','s','n'和'g '邊框上沒有黑色,所以我不想要邊框 –
我的第二點:如果你所做的只是創建圖形,這樣你就可以在不同尋常的字體中使用文本,你可以在純HTML/CSS中做到這一點,即使使用特殊字體,使用CSS'@ font-face'。適用於所有瀏覽器。有關詳細信息,請參閱http://randsco.com/index.php/2009/07/04/p680和http://paulirish.com/2009/bulletproof-font-face-implementation-syntax/。 – Spudley