Writing text on an image

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

Post Reply
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

Writing text on an image

Post by psychotomus »

How can I write text on an image?
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Have a look in the GD subforum... We were just talking about that...
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

Post 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(); 
}
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

Post 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.
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

Post 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?
Post Reply