I have an issue with my PHP code.
I want to add text to an image.
When using imagestring(), the image displays fine with the text on top, but it’s written very very small.
And it’s impossible to increase the size with imagestring().
I saw that it’s rather recommended to use imagettftext(), but when I use this function, the image doesn’t display.
I get no errors, it just displays the alt tag text.
I’ve tried dozens and dozens of different function calls but none have worked.
Here’s my code:
$idQuiz = $_GET['qz'];
$user = UtilisateursManager::getList(null, ['idUtilisateur'=>$_SESSION['utilisateur']->getIdUtilisateur()])[0];
$name = $user->getPrenomUtilisateur().' '.$user->getNomUtilisateur();
$font = './FONTS/RedditMono-Black.ttf';
$fontSize = 50;
$img = "./IMG/certificatRealisation.jpg";
$image = imagecreatefromjpeg($img);
$color = imagecolorallocate($image, 255, 0, 0);
// imagestring($image, 5, 600, 700, $name, $color);
imagettftext($image, 52, 0, 500, 600, $color, $font, $name);
header("Content-type: image/jpeg");
imagejpeg($image);
imagedestroy($image);