I was trying to make a signature creator, everything seemed to be working except the image creation part, it shows up the dead image icon.
Here is the code
<?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");
}
}
?>
How come it doesnt create the image?
I'm not a pro in this, still a newbie so pardon if i created any mistakes.
Thanks
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.