Skip to content
Advertisement

can I have multiline text with GD and PHP?

I’m trying to output multiline text with GD+PHP but can’t get it working. my php knowledge is really basic. here’s the code, any idea on how to output 2 or 3 lines of text?

$theText = (isset($_GET['caption']))? stripslashes($_GET['caption']) :'';
imagettftext($baseImage, $textSize, $textAngle, $textXposition, $textYposition, $textColor, $fontName, $theText);

Advertisement

Answer

imagettftext($baseImage, $textSize, $textAngle, $textXposition, $textYposition, $textColor, $fontName, $theText);
imagettftext($baseImage, $textSize, $textAngle, $textXposition+(25), $textYposition, $textColor, $fontName, $theText);
imagettftext($baseImage, $textSize, $textAngle, $textXposition+(50), $textYposition, $textColor, $fontName, $theText);

you have to add x pixel to move it downwards to the X position. keep in mind that your whole image should be high and wide enough to fit the text.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement