Text aligning with imagettftext();

How can I change the alignment of text I output to right or center?


It’s based on co-ordinates. You can’t specifically ask it to align left centre or right because it’s an image, but you can align it using co-ordnates.

See here.

You actually can’t really choose a font alignment with imagettftext, what you can do is determine the size of the text that will be produced with imageftbbox and then align the x & y where you are going to place the text in the image.

I’ve worked alot with it for www.writeonit.org where we let the user write on some images and the alignment part was a real pain :slight_smile: Anyhow, if you have to align multilines text I’d suggest to split the text and do an imagettftext for each line.