Page 1 of 1

Images and text

Posted: Tue Apr 01, 2003 4:22 am
by Luis Almeida
Hi,

After doing the following code I just can´t output any text with "ECHO" or "PRINTF" functions.
I mean. It does all the graphics stuff but it just don´t execute the line "echo "Image 1;"
Can any one help me please???

$pic=imageCreate($boxWidth,$boxHeight);
imageFilledRectangle($pic, $boxLeft+1, $boxTop, $boxRight-1, $boxBottom, imageColorAllocate($pic,$boxGray,$boxGray,$boxGray));
imageFilledRectangle($pic, $boxLeft, $boxTop+1, $boxRight, $boxBottom-1, imageColorAllocate($pic,$boxGray,$boxGray,$boxGray));
Header("Content-type: image/png");
imagePNG($pic);
imageDestroy($pic);
echo "IMAGE 1";

Posted: Tue Apr 01, 2003 5:25 am
by twigletmac

Posted: Tue Apr 01, 2003 5:56 am
by Luis Almeida
I know that I can use "ImageString" to write on images but my problem is to write on the page using "ECHO" or "Printf" after displaying the image

Posted: Tue Apr 01, 2003 5:57 am
by ILoveJackDaniels
You've got a line saying this: Header("Content-type: image/png"); so the browser thinks the page being displayed is a picture. It won't display normal text as well.

Posted: Tue Apr 01, 2003 6:17 am
by twigletmac
As ILoveJackDaniels said, you can't tell the browser you want to display an image and then expect it to be able to deal with text as well. If you want to add text you can either put the text on the image or, if for instance the image creation script was in a file called imagecreate.php, you could do:

Code: Select all

<img src="imagecreate.php" alt="PHP generated image" />
<p>Image 1</p>
Mac

Thanks

Posted: Tue Apr 01, 2003 6:22 am
by Luis Almeida
Thank you for concerning
that worked just fine