Avatar of jallenmorris
jallenmorris asked on

PHP GD function using imagettftext() more than one time on one picture

I am using the GD function to generate text on a PNG image.  I can get it work without problems, but I have more than one item of text I want to display.  For example, but image has 4 squares and I want to place different text into each square.  How can I do that?

I tried using the imagettftext() function more than once, but it generated an error and nothing displayed but the red x in the top left of where the PNG image should have been.

As you can see the commented portion I have the variable $text2 and $two = ....  I have tried it both ways with the variable in front of the function and without the variable infront of the function.  Either way, the second time I try to put in imagettftext() it generates and error.

Can anyone help me figure this out?
header('Content-type: image/png');
$im = imagecreatefrompng ("Legaloval20.png");
$color = imagecolorallocate($im, 0, 0, 0);
$text = $_GET['text'];
$size = 14;
//                             angle x    y
$one = imagettftext($im, $size, 10, 144, 123, $color, $font, $text);
//$text2 = "Spaces"
//$two = imagettftext($im, $size, 10, 164, 143, $color, $font, $text2);

Open in new window


Avatar of undefined
Last Comment

8/22/2022 - Mon

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.