我試圖做一個簽名創建者,除了圖像創建部分,一切似乎都在工作,它顯示了死圖像圖標。imagecreatefromjpeg問題[圖像不顯示]
下面是代碼
<?php
define('IP', '62.210.182.42');
include "koneksi.php";
if(isset($_GET['user']))
{
$query = $koneksi->prepare("select * from `playerdata` where `user` = ?");
$query->execute(array($_GET['user']));
$data = $query->fetch();
$font_dir = 'fonts/';
$text = 'Undefined';
$font = 'Transformers Movie.ttf';
$font2 = 'pricedown bl.ttf';
if($query->rowCount() > 0)
{
$type_space = imagettfbbox(25, 0, $font_dir.$font, $text);
$image_width = abs($type_space[4] - $type_space[0]) + 20;
$image_height = abs($type_space[5] - $type_space[1]) + 20;
$im = imagecreatefromjpeg("img/signature.jpg");
imagesavealpha($im, true);
imagealphablending($im, true);
$bg = imagecolorallocatealpha($im, 255, 255, 255, 127);
$putih = imagecolorallocate($im, 255, 255, 255);
$hitam = imagecolorallocate($im, 0, 0, 0);
$abu = imagecolorallocate($im, 0, 100, 255);
$biru = imagecolorallocate($im, 245, 184, 0);
imagefill($im, 0, 0, $bg);
function CreateTitle($name = "Undefined", $title = "GG Player")
{
$size_title = 20;
global $hitam, $putih, $font, $font_dir, $im, $biru, $font2;
$gambat = imagettftext($im, $size_title, 0, 26, 30, $hitam, $font_dir.$font2, $name);
$gambat = imagettftext($im, $size_title, 0, 27, 31, $hitam, $font_dir.$font2, $name);
$gambat = imagettftext($im, $size_title, 0, 28, 32, $hitam, $font_dir.$font2, $name);
$gambat = imagettftext($im, $size_title, 0, 29, 34, $hitam, $font_dir.$font2, $name);
$gambat = imagettftext($im, $size_title, 0, 25, 29, $biru, $font_dir.$font2, $name);
$gambat = imagettftext($im, $size_title, 0, 25, 29, $biru, $font_dir.$font2, $name);
$gambat = imagettftext($im, $size_title-6, 0, 250, 27, $hitam, $font_dir.$font2, $title);
$gambat = imagettftext($im, $size_title-6, 0, 251, 28, $hitam, $font_dir.$font2, $title);
$gambat = imagettftext($im, $size_title-6, 0, 252, 29, $hitam, $font_dir.$font2, $title);
$gambat = imagettftext($im, $size_title-6, 0, 253, 30, $hitam, $font_dir.$font2, $title);
$gambat = imagettftext($im, $size_title-6, 0, 250, 27, $biru, $font_dir.$font2, $title);
$gambat = imagettftext($im, $size_title-6, 0, 250, 27, $biru, $font_dir.$font2, $title);
}
function CreateStats($nomer = 1, $baris = 1, $name, $size_title = 18)
{
$width = 60;
$height = 31;
global $biru, $hitam, $font, $font_dir, $im, $biru;
for($a = 1; $a < $nomer; $a++)
$width+=19;
for($a = 1; $a < $baris; $a++)
$height+=130;
$gambat = imagettftext($im, $size_title-5, 0, $height + 1, $width + 1, $hitam, $font_dir.$font, $name);
$gambat = imagettftext($im, $size_title-5, 0, $height + 2, $width + 2, $hitam, $font_dir.$font, $name);
$gambat = imagettftext($im, $size_title-5, 0, $height, $width, $biru, $font_dir.$font, $name);
}
function CreateIP($ip = IP)
{
$size_title = 15;
global $biru, $hitam, $font, $font_dir, $im, $biru;
$gambat = imagettftext($im, $size_title-5, 0, 320, 102, $hitam, $font_dir.$font, $ip);
$gambat = imagettftext($im, $size_title-5, 0, 321, 103, $hitam, $font_dir.$font, $ip);
$gambat = imagettftext($im, $size_title-5, 0, 322, 104, $hitam, $font_dir.$font, $ip);
$gambat = imagettftext($im, $size_title-5, 0, 323, 105, $hitam, $font_dir.$font, $ip);
$gambat = imagettftext($im, $size_title-5, 0, 320, 102, $biru, $font_dir.$font, $ip);
$gambat = imagettftext($im, $size_title-5, 0, 320, 102, $biru, $font_dir.$font, $ip);
}
if($data['level'] == 1)
$title = "Junior Administrator ";
else if($data['level'] == 2)
$title = "Junior Administrator ";
else if($data['level'] == 3)
$title = "Moderator";
else if($data['level'] == 4)
$title = "Senior Administrator ";
else if($data['level'] == 5)
$title = "Head Administrator ";
else if($data['level'] == 6)
$title = "Co-Owner ";
else if($data['level'] == 1337)
$title = "Owner ";
else
$title = "YGG Player ";
if($data['level'] == 1)
$title .= "Basic VIP ";
else if($data['level'] == 2)
$title .= "Silver VIP ";
else if($data['level'] == 3)
$title .= "Gold VIP ";
if($data['YG'] == 1)
$title .= "TG Member";
else if($data['YG'] == 0)
$title .= "Not TG";
CreateTitle($data['user'], $title);
CreateStats(1, 1, "Score : ".$data['score']);
CreateStats(2, 1, "Money : ".$data['money']);
CreateStats(3, 1, "Kills : ".$data['kills']);
CreateStats(1, 2, "Deaths : ".$data['deaths']);
$total = $data['kill']/$data['deaths'];
CreateStats(2, 2, "K/D Ratio : ".round($total, 1));
CreateStats(3, 2, "Bank : ".$data['Bank']);
CreateIP();
header('Content-type: image/jpeg');
imagejpeg($im);
}
else
{
header("Location:signature.html");
}
}
?>
爲什麼它不創造的形象?
我不是一個職業球員,如果我犯了錯誤,還是一個新手。
感謝
首先確保三件事,在你的頭函數調用之前沒有任何類型的輸出,並且你的字體文件名正是你正在使用的,並且在你的服務器上啓用了最重要的gd庫擴展。 –
我如何確保gd lib擴展已啓用? –
<?php echo phpinfo(); ?> –