Creating an image and sending to the browser
Posted: Thu Jul 22, 2010 6:16 am
I have a script that does a number of things. Other scripts include it and then call functions which output things to the browser.
I'd like to be able to have a function like display_graph() which then sends a graph to the broswer!
That will work if the display graph is in its own file and one does say
But I cannot get a function like say display_graph(); to output the image call and the image
eg
Any ideas???
I'd like to be able to have a function like display_graph() which then sends a graph to the broswer!
That will work if the display graph is in its own file and one does say
Code: Select all
<img src="display_graph.php"/>eg
Code: Select all
function display_graph()
{
echo '<img src="'.graph();.'"/>';
}
function graph()
{
// simple working image for now... to demonstarte principle I would like to achieve.
header ("Content-type: image/png");
$newImg = ImageCreate(250,250);
$skyblue = ImageColorAllocate($newImg,136,193,255);
ImageFill($newImg,0,0,$skyblue);
ImagePNG($newImg);
ImageDestroy($newImg);
}