I have a table that is generated out of a datbase. Many of the cells need to have a dynamically generated image containing a tag from the database. The image is supposed to have a background color with a few characters of text from the database superimposed (black text on yellow background or black on lightblue, or black on green).
I'm generating the images with a call to a function that creates the image in a .png file. The cell images seem correct but the text is not. It's obvious the PNG file is getting overwritten before HTML can pick up the image and stream it out.
I need to generate each image in-line, e.g. with no file being written. Over a hundred images are being created and writing to a single file is not only inefficient, it doesn't work correctly. But I can't seem to come up with a syntax that PHP likes to try to generate each image in-line - on the fly.
Especially troubling is when I put a header() command in the image generation function. The browser (properly) complains about already having sent HTML headers.
Here's part of my image generation code. It's a function that's included in the PHP file that generates the table:
// header("Content-Type: image/png");
// ID label passed in as $loc
// create the image
$im = ImageCreate(20,80);
// allocate colors
$green = ImageColorAllocate($im,0,255,0);
$black= ImageColorAllocate($im,0,0,0);
$yellow = ImageColorAllocate($im,255,255,0);
$pblue = ImageColorAllocate($im,0,255,255);
// determine background color
switch($avail) {
case 0:
ImageFilledrectangle($im,0,0,20,80,$green);
break;
case 1:
ImageFilledrectangle($im,0,0,20,80,$yellow);
break;
case 2:
ImageFilledrectangle($im,0,0,20,80,$pblue);
break;
}
ImageStringUp($im,4,0,50,"A99",$black);
ImagePNG($im,"vtable_image.png");
ImageDestroy($im);
return;
Any ideas?
Thanks,
Art G.