hello everyone..
i would to ask about my simple code here.. it's not working..
i actually want to display a forum badge which is data are received from the database. And i stucked at putting the avatar to a portion of the badge..i mean it looks like facebook profile badge...
i created a background image using imagecreatefrompng() function..
can anybdy with this?
<?php
define('PUN_ROOT', '../');
require PUN_ROOT.'include/common.php';
$id = isset($_GET['id']) ? base64_decode($_GET['id']) : 0;
//PHP's GD class functions can create a variety of output image
//types, this example creates a jpeg
header("Content-type: image/png");
//open up the image you want to put text over
$im = imagecreatefrompng("testing.png");
//The numbers are the RGB values of the color you want to use
$black = imagecolorallocate($im, 0, 51, 102);
$sql = $db->query('SELECT username, num_posts FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to fetch new password', __FILE__, __LINE__, $db->error());
$result = $db->fetch_assoc($sql);
$Uname = $result['username'];
$Nopost = 'No. of posts» '.$result['num_posts'];
//font
$font = './Verdana.ttf';
//write data to the image
imagettftext($im, 10, 0, 20, 12, $black, $font, $Uname);
imagettftext($im, 10, 0, 20, 30, $black, $font, $Nopost);
//path to avatar directory
$avapath = '../img/avatars/'.$id.'png';
// Copy and merge avatar to the backgroud
// Something wrong here.. =(
$src = imagecreatefrompng($avapath);
imagecopymerge($im, $src, 10, 10, 0, 0, 100, 47, 75);
imagepng($im);
imagedestroy($im);
?>