Settings | Sign in | Sign up

There are currently 4 posts.

GD庫輸出帶有字體的文字

Floor 1 巨大八爪鱼 6/13/15 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);
?>
Floor 2 巨大八爪鱼 6/13/15 10:04
無需打開字體文件,只需指定文件路徑。
Floor 3 巨大八爪鱼 6/13/15 10:05

文字顏色是隨機生成的!
Floor 4 巨大八爪鱼 6/13/15 10:05

Content converter:

Reply the post
Content:
User: You are currently anonymous.
Captcha:
Unclear? Try another one.
©2010-2025 Purasbar Ver3.0 [Mobile] [Desktop]
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported license.