Я настраиваю динамические изображения подписи для моих пользователей, и я хочу, чтобы они могли поместить их имя пользователя на изображение. Я могу сделать это просто отлично, но поскольку имена пользователей различаются по длине, и я хочу правильно выровнять имя пользователя, как я могу это сделать, когда мне нужно установить координаты x и y.
$im = imagecreatefromjpeg("/path/to/base/image.jpg");
$text = "Username";
$font = "Font.ttf";
$black = imagecolorallocate($im, 0, 0, 0);
imagettftext($im, 10, 0, 217, 15, $black, $font, $text);
imagejpeg($im, null, 90);