- #1
- 4,652
- 37
I was experimenting with the imagecreatefrompng() function in php. There was an example here:
http://us2.php.net/imagecreatefrompng
I tried to modify it to use an image called full.png in my img folder.
aaaimage.php
I'm not sure what to do with the HTML. I tried the simplest idea:
display.htm
But that does nothing. I just get a broken image tag. I am not really clear on what the function returns, they say it is an
"image identifier" but I don't know what that means.
Any advice? Thanks.
http://us2.php.net/imagecreatefrompng
I tried to modify it to use an image called full.png in my img folder.
aaaimage.php
Code:
#!/usr/local/bin/php
<?php
function LoadPNG($imgname)
{
$im = @imagecreatefrompng($imgname); /* Attempt to open */
if (!$im) { /* See if it failed */
$im = imagecreatetruecolor(150, 30); /* Create a blank image */
$bgc = imagecolorallocate($im, 255, 255, 255);
$tc = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 150, 30, $bgc);
/* Output an errmsg */
imagestring($im, 1, 5, 5, "Error loading $imgname", $tc);
}
return $im;
}
header("Content-Type: image/png");
$img = LoadPNG("img/full.png");
imagepng($img);
?>
I'm not sure what to do with the HTML. I tried the simplest idea:
display.htm
Code:
<HTML>
<HEAD></HEAD>
<BODY>
This is a test.<BR/>
<img src="aaaimage.php" />
</BODY>
</HTML>
But that does nothing. I just get a broken image tag. I am not really clear on what the function returns, they say it is an
"image identifier" but I don't know what that means.
Any advice? Thanks.