troubleshooting Question

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

Avatar of jallenmorris
jallenmorris asked on
PHP
1 Comment1 Solution578 ViewsLast Modified:
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'];
$font="fonts/ariblk.ttf";
$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);
 
imagepng($im);
imagedestroy($im);
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 1 Comment.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros