目前共有4篇帖子。 內容轉換:不轉換▼
 
點擊 回復
321 3
GD庫輸出帶有字體的文字
一派護法 十九級
1樓 發表于:2015-6-13 10:03
<?php
header("Content-type:image/png");

$im = imagecreatetruecolor(550, 70);
$colour = imagecolorallocate($im, 224, 223, 238);
imagefill($im, 0, 0, $colour);

$fontfile = "/var/www/arslanbar/2/fonts/DejaVuSans.ttf" ;
$colour = imagecolorallocate($im, mt_rand(0, 100), mt_rand(50, 150), mt_rand(100, 200));
imagettftext($im, 35, 0, 4, 38, $colour, $fontfile, "Which is the best one?");

$fontfile = "/var/www/arslanbar/2/fonts/showg.ttf" ;
$colour = imagecolorallocate($im, mt_rand(0, 100), mt_rand(50, 150), mt_rand(100, 200));
imagettftext($im, 22, 0, 4, 65, $colour, $fontfile, "Do you think they are important?");

imagepng($im);
imagedestroy($im);
?>
一派護法 十九級
2樓 發表于:2015-6-13 10:04
無需打開字體文件,只需指定文件路徑。
一派護法 十九級
3樓 發表于:2015-6-13 10:05

文字顏色是隨機生成的!
一派護法 十九級
4樓 發表于:2015-6-13 10:05

回復帖子

內容:
用戶名: 您目前是匿名發表
驗證碼:
(快捷鍵:Ctrl+Enter)
 

本帖信息

點擊數:321 回複數:3
評論數: ?
作者: 巨大八爪鱼
最後回復:巨大八爪鱼
最後回復時間:2015-6-13 10:05
 
©2010-2024 Arslanbar Ver2.0
除非另有聲明,本站採用創用CC姓名標示-相同方式分享 3.0 Unported許可協議進行許可。