Page 1 of 1

Displaying a fresh generated image.

Posted: Sat Jan 17, 2004 12:36 pm
by fastfingertips
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);
    }
?>

Posted: Sat Jan 17, 2004 1:03 pm
by Gen-ik
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(); ?>