PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
fastfingertips
Forum Contributor
Posts: 242 Joined: Sun Dec 28, 2003 1:40 am
Contact:
Post
by fastfingertips » Sat Jan 17, 2004 12:36 pm
I have generated a new image, how can i display it into other file where i have also other texts?
My function looks:
Code: Select all
<?php
header("Content-type: image/png");
function WriteImage($string)
{
$im = imagecreatefrompng("bgimage.png");
$orange = imagecolorallocate($im, 220, 210, 60);
imagestring($im, 5, 10, 4, $string, $orange);
imagepng($im);
imagedestroy($im);
}
?>
Gen-ik
DevNet Resident
Posts: 1059 Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.
Post
by Gen-ik » Sat Jan 17, 2004 1:03 pm
Put your image code into a seperate PHP file and include it in HTML with something like
<img src="image.php?string=hello" alt="" />
image.php would look like this...
Code: Select all
<?php ob_start();
$string = $_GET["string"];
$im = imagecreatefrompng("bgimage.png");
$orange = imagecolorallocate($im, 220, 210, 60);
imagestring($im, 5, 10, 4, $string, $orange);
header("Content-type: image/png");
imagepng($im);
imagedestroy($im);
ob_end_flush(); ?>