Okay, my problem here is I want to display the dynamically generated images on a webpage after they have been generated and provide a link for the user to use the image. When I try to echo the image:
echo '<img src="link/sig.php?username='.$_GET['username'].'&fakeparm=.png />';
The webpage displays the image fine, but with the addition of a million weird characters. Below is the image creation snippet.
$image_link = 'image.png';
$image = imagecreatefrompng($image_link);
$font_colour = imagecolorallocate($image, 0, 0, 0);
$font_size = 3;
$x = array('28', '80', '135', '188', '240');
$y = array('8', '29', '52', '77', '100');
$i = '0';
$a = '0';
foreach($stat as $s_key => $value){
imagestring($image, $font_size, $x[$a], $y[$i], $value[1], $font_colour);
$i++;
if($i == '5'){
$i = '0';
$a++;
}
}
imagestring($image, $font_size, '230', '100', 'Total:'. $overall[1], $font_colour);
imagestring($image, $font_size, '240', '75', '' . $username, $font_colour);
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
Value of $stat
.
$stats = explode("
", $website);
$overall = explode(",", $stats[0]);
$stat['att'] = explode(",", $stats[1]);
$stat['def'] = explode(",", $stats[2]);
$stat['str'] = explode(",", $stats[3]);
$stat['hp'] = explode(",", $stats[4]);
$stat['rng'] = explode(",", $stats[5]);
$stat['pry'] = explode(",", $stats[6]);
$stat['mag'] = explode(",", $stats[7]);
$stat['ck'] = explode(",", $stats[8]);
$stat['wc'] = explode(",", $stats[9]);
$stat['flt'] = explode(",", $stats[10]);
$stat['fsh'] = explode(",", $stats[11]);
$stat['fm'] = explode(",", $stats[12]);
$stat['cra'] = explode(",", $stats[13]);
$stat['smi'] = explode(",", $stats[14]);
$stat['min'] = explode(",", $stats[15]);
$stat['her'] = explode(",", $stats[16]);
$stat['ag'] = explode(",", $stats[17]);
$stat['th'] = explode(",", $stats[18]);
$stat['sl'] = explode(",", $stats[19]);
$stat['frm'] = explode(",", $stats[20]);
$stat['rc'] = explode(",", $stats[21]);
$stat['hun'] = explode(",", $stats[22]);
$stat['cs'] = explode(",", $stats[23]);
Note: Image is generated fine, everything works... I want to display the generated image on a webpage instead of being forwarded to the image itself...
Make sure there are no characters or browser output before you declare your headers. Not even spaces. Otherwise the browser may try and read the image as html giving you your "million weird characters".
You have not closing the img tag...
echo '<img src="link/sig.php?username='.$_GET['username'].'&fakeparm=.png" />';
instead of
echo '<img src="link/sig.php?username='.$_GET['username'].'&fakeparm=.png />';