I have the following function stored in a function.php file which is included for every page on a site:
function MenuImage ($image, $words) {
header("Content-Type: image/png");
$im = @ImageCreateFromPng($image);
if ($im == "") {
echo "error - image missing";
} else {
$white = ImageColorAllocate($im, 255, 255, 255);
ImageString($im, 3, 6, 4, $words, $white);
ImagePng($im);
ImageDestroy($im);
return $im;
}
}
Which I call using:
MenuImage("images/menuimg.png", "Services")
at certian places in the script. the only problem is that I need a workaround for the 'headers already set' problem. I realize that all headers must be called before any HTML but this function requires that the header be set for the image... is this correct? and any suggestions on how to fix it?