PGP GD page source code shown instead of image

I’m having troubles generating images with GD. I’m trying to create a chart but whenever the image needs to be generated the page source code is being shown instead of the page and the generated image.

I have tried 2 different scripts(PHPgraphlib and JPgraph) to create the graphs and none of them work, so the problems must be GD related.

I have tried to first save the image to file and then display it. This gives me a white image. I do not have the ability to upload screenscaps but here is text output from phpinfo() for GD support

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  

I have searched for a sollution but came up empty. I can verify thati have no extra code or whitespace after the php and/or html tags

i could post some output code that is shown instead of the image but its not human readable anyways.

Any help with this is welcome.

WebServer runs on test envirement S2012 R2 with WAMP

I tried that the GD is loaded with png support with the following code:

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";
    }

Output:

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

Code to create graph (with dummy testdata)

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s