So I am working on a system for work where certificates are automatically generated. I have this working but I want to make it better, instead of a super long case statement that centers the name of the person on the image by absolute positioning I want to make it work automatically. I have thought of a algorithm that will work but I need one part to make it complete. Basically the algorithm works like this:
(Width of Image / 2) - (Width of Name /2) and $xpos = the result.
The code to write the text to the image is:
imagettftext($image, 48, 0, $xpos, 600, $textColor, $font, ucwords(strtolower($Name)));
Is there anyway to find the Width of the Name? I can get the width of the Image but I cannot find the width of the Name. Currently the $xpos is just a defined number. Any help?