显示PGP GD页面源代码而不是图像

时间:2015-10-29 14:21:19

标签: php gd

我在使用GD生成图像时遇到了麻烦。我正在尝试创建一个图表但是无论何时需要生成图像,都会显示页面源代码而不是页面和生成的图像。

我已经尝试了两个不同的脚本(PHPgraphlib和JPgraph)来创建图形,但没有一个工作,所以问题必须与GD相关。

我尝试先将图像保存到文件然后再显示。这给了我一个白色的图像。我无法上传screenscaps,但这里是来自phpinfo()的文本输出,用于GD支持

gd

GD Support  enabled  
GD Version  bundled (2.1.0 compatible)  
FreeType Support  enabled  
FreeType Linkage  with freetype  
FreeType Version  2.4.10  
GIF Read Support  enabled  
GIF Create Support  enabled  
JPEG Support  enabled  
libJPEG Version  9 compatible  
PNG Support  enabled  
libPNG Version  1.5.18  
WBMP Support  enabled  
XPM Support  enabled  
libXpm Version  30411  
XBM Support  enabled  
WebP Support  enabled  

我已经搜索过溶剂但是空了。我可以验证在php和/或html标签之后没有额外的代码或空格

我可以发布一些显示的输出代码而不是图像,但不管怎样它都不是人类可读的。

欢迎任何帮助。

WebServer在带有WAMP的测试环境S2012 R2上运行

我尝试使用以下代码加载GD支持:

if (extension_loaded('gd')) {
  echo "\nGD support is -Loaded-";
}else{
  echo "\nGD support is == NOT == loaded ";
}
if(function_exists('gd_info')){
  echo "\nGD function support is -Available- ";
}else{
  echo "\nGD function support is == NOT == available ";
}

if(function_exists('imagepng')){
  echo "\nimagepng() -Exists-";
}else{
  echo "\nimagepng() ==== DOES NOT ==== Exist";
}


if(function_exists('imagejpeg')){
  echo "\nimagejpeg() -Exists-";
}else{
  echo "\nImage Function ==== DOES NOT ==== Exists";
    }

输出:

GD support is -Loaded- 
GD function support is -Available- 
imagepng() -Exists- 
imagejpeg() -Exists- 

创建图表的代码(使用虚拟测试数据)

$graph = new PHPGraphLib(650,200);
$data = array("1" => .0032, "2" => .0028, "3" => .0021, "4" => .0033, 
"5" => .0034, "6" => .0031, "7" => .0036, "8" => .0027, "9" => .0024, 
"10" => .0021, "11" => .0026, "12" => .0024, "13" => .0036, 
"14" => .0028, "15" => .0025);
$graph->addData($data);
$graph->setTitle('Power Useage in KW');
$graph->setBars(false);
$graph->setLine(true);
$graph->setDataPoints(true);
$graph->setDataPointColor('maroon');
$graph->setDataValues(true);
$graph->setDataValueColor('maroon');
$graph->setGoalLine(.0025);
$graph->setGoalLineColor('red');
$graph->createGraph();

0 个答案:

没有答案