Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Output image on a web background using GD functions

Status
Not open for further replies.

OOP

Programmer
Feb 5, 2001
94
SG
Hello,
i just started php and i having a problem to open an image from my directory and show it on the browser with a background. It may seems like a piece of cake but i really can't figure it out. I used the following codes;

<body bgcolor=#000000>

<?PHP
$im=imagecreatefrompng("humanp.png");
header('content-type: image/png');
imagepng($im);
imagedestroy($im);
?>

It works fine if i ignore the background setting and only display the image and vice versa. They just cannot produced the desired output when placed together. Is there something i miss out? Any help/comment would be appreciated. Thanks.
 
You have to enclose your php statement into a img tag like this :

<body bgcolor=#000000>

<img src="<?php your php code here ?>">

and it will work fine.

 
and of course a better solution would be to create a new php file which generate the image, then call it through your img tag

<body....>

<img src="generatepng.php">

more reusable...
 
Now i got the idea. [smarty]
Thanks for the prompt reply, gaudibri.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top