Creating Images using separate PHP files.
| From: | Matt Glaves | Date: | Mon, 16 Oct 2000 20:56:40 +0000 |
| Subject: | Creating Images using separate PHP files. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-20446@lists.php.net to get a copy of this message | ||
I have crated a class to generate a graph. If I include the class and the
function calls in one file, it displays the image correctly. If I put the
function calls in a separate file and call the class, a header error is
displayed. I tried moving the header call to the file w/the functions,
but it only displays a blank page.
Things basically look like this:
------
<?
/*
Header("Content-type: image/png");
I tried adding this here but it generates header errors
*/
require('graphclass.php');
$graph = new GraphMe("Graph Title",500);
$graph->addbar("one",1);
$graph->addbar("two",2);
$graph->addbar("three",3);
$graph->addbar("four",4);
$graph->drawgraph();
?>
------
And here is basically what happens when the $graph->drawgraph function is
called:
------
Header("Content-type: image/png");
$image = imagecreate($this->width(),$this->height());
ImagePng($image);
ImageDestroy($image);
------
I assume that the first file needs to state that an image is coming and
not a html file, but when I add the Header call to the first function it
seems to think my class is printing to stdout.
Any help would be wonderful!
thanks,
--
Matt Glaves
Systems Engineer
Pinnacle Online
www.pinn.net