Page 1 of 1

Writing text on an image

Posted: Sun Apr 23, 2006 3:56 pm
by psychotomus
How can I write text on an image?

Posted: Sun Apr 23, 2006 3:57 pm
by timvw
Have a look in the GD subforum... We were just talking about that...

Posted: Sun Apr 23, 2006 4:04 pm
by psychotomus
I was searching and didnt find nothing what im trying to do.

everything I found creates the image. i want to use an image stored on my Web Server, say a star galaxy background. or an image named background.png or background.jpg


this is what I found.
i dont want to create a new image. i want to use a previous image then write on that image.

Code: Select all

<?php 
if($_POST['text2write']){ 
$im = imagecreate(100, 30); 
// white background and blue text 
$bg = imagecolorallocate($im, 255, 255, 255); 
$textcolor = imagecolorallocate($im, 0, 0, 255); 
imagestring($im, 5, 0, 0, $_POST['text2write'], $textcolor); 
header("Content-type: image/png"); 
imagepng($im); 
exit(); 
}

Posted: Sun Apr 23, 2006 4:12 pm
by feyd
You have to create a new image, but you can use an existing image as the base for this new image. imagecreatefrompng() for example.

Posted: Sun Apr 23, 2006 4:18 pm
by psychotomus
feyd wrote:You have to create a new image, but you can use an existing image as the base for this new image. imagecreatefrompng() for example.
just found that at php.net ^_^ thanks.

Posted: Sun May 14, 2006 1:35 pm
by psychotomus
how can I save the file with the text written on it to the server so the new imag will have the text on it?