PHP创建一个png图像

时间:2012-06-14 05:11:43

标签: php image

我正在尝试创建一个PHP图像,虽然我遇到了一些问题。 我想在php文件中添加一个URL。 url(global.php)包含获取特定用户的用户名并将某些图像文件输入到php图像的信息。

但每当我添加global.php链接时,图像都不会显示出来。 我的主要问题是,我能够添加文件链接,还可以添加echo''之类的内容;到php图像文件?

    <?php
// MySQL Connect & Select
mysql_connect('localhost', 'root', 'password') or die('Error connecting to mysql');
mysql_select_db('database');

$result = mysql_query("SELECT * FROM users WHERE username = '".stripslashes(trim(htmlspecialchars(mysql_real_escape_string(mysql_escape_string($_GET['user'])))))."'");
$row = mysql_fetch_array($result);
$result_stats = mysql_query("SELECT * FROM user_stats WHERE id = '".$row['id']."'") or die("USER_STATS: ".mysql_error());
$row_stats = mysql_fetch_array($result_stats);
$result_info = mysql_query("SELECT * FROM user_info WHERE user_id = '".$row['id']."'") or die("USER_INFO: ".mysql_error());
$row_info = mysql_fetch_array($result_info);

$text[1] = "Hiya, ".$row['username']."!";
$text[2] = "Your last login was ".@date("d-M-Y\n H:i",$row['last_online']).". We missed you :)";
$text[3] = "Do you know the Rare! Way";
$text[4] = "".$row['username']."?";
$text[5] = "I do!";
$text[6] = "Be sure to follow the Rare! Way. \n \n When you follow the Way, you're giving \n yourself the best experience on Rare! that you \n can ever get! Stay tuned for more.";

// Colors
$image      = imagecreatefrompng('userbanner/hotel.png');
$black      = imagecolorallocate($image, 0, 0, 0);
$white      = imagecolorallocate($image, 250, 250, 250);
$grey       = imagecolorallocate($image, 77, 77, 77);

// Font
$volterB    = 'userbanner/Ubuntu-B.ttf';
$volder     = 'userbanner/Ubuntu-M.ttf';
$conden     = 'userbanner/Ubuntu-L.ttf';
$light      = 'userbanner/Ubuntu-Regular.ttf';


$userimage1 = imagecreatefrompng("http://www.habbo.com/habbo-imaging/avatarimage?figure=".$row['look']."&direction=2&head_direction=2&gesture=spk&img_format=png");
imagecopy($image, $userimage1, 420, 288, 0, 0, 64, 110);




$userimage  = imagecreatefrompng("http://www.habbo.com/habbo-imaging/avatarimage?figure=".$row['look']."&direction=2&head_direction=2&gesture=sml&img_format=png");
imagecopy($image, $userimage, 220, 628, 0, 0, 64, 110);

// Create image from text
imagettftext($image, 15, 0, 20, 465, $black, $volterB, $text[1]);
imagettftext($image, 8, 0, 20, 483, $black, $conden, $text[2]);
imagettftext($image, 18, 0, 510, 300, $black, $volterB, $text[3]);
imagettftext($image, 15, 0, 510, 330, $black, $volterB, $text[4]);
imagettftext($image, 15, 0, 345, 333, $black, $volder, $text[5]);
imagettftext($image, 10, 0, 520, 360, $grey, $light, $text[6]);
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);



?>

如果我不清楚,请告诉我。谢谢:))

0 个答案:

没有答案