0

好的,我的问题是我想在生成后在网页上显示动态生成的图像,并为用户提供使用图像的链接。当我尝试回显图像时:

echo '<img src="link/sig.php?username='.$_GET['username'].'&fakeparm=.png />';

网页显示图像很好,但添加了一百万个奇怪的字符。下面是图像创建片段。

$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);

的值$stat

$stats = explode("\n", $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]);

注意:图像生成正常,一切正常...我想在网页上显示生成的图像,而不是转发到图像本身...

4

2 回答 2

1

您还没有关闭 img 标签...

 echo '<img src="link/sig.php?username='.$_GET['username'].'&fakeparm=.png" />';

代替

 echo '<img src="link/sig.php?username='.$_GET['username'].'&fakeparm=.png />';
于 2013-04-29T18:15:14.353 回答
0

在声明标题之前,请确保没有字符或浏览器输出。甚至没有空格。否则,浏览器可能会尝试将图像读取为 html,从而为您提供“百万怪异字符”。

于 2013-04-29T18:10:33.700 回答