I am trying to create an image by using PHP. This image is supposed to have text on it. I am only able to get the text displayed by using imagestring function, but this function only allows font size of upto 5. As it turns out, this is too small or tiny of a font for me. Then, I learned you can have text as big as you want on your image by using imagettftext function. This function doesn't work for me at all. I found this code in another stackoverflow question while I was researching on this issue.
<?php
$image = imagecreate(400,300);
$blue = imagecolorallocate($image, 0, 0, 255);
$white = ImageColorAllocate($image, 255,255,255);
if(!isset($_GET['size'])) $_GET['size'] = 44;
if(!isset($_GET['text'])) $_GET['text'] = "Hello, world!";
// Set the enviroment variable for GD
putenv('GDFONTPATH=' . realpath('.'));
// Name the font to be used (note the lack of the .ttf extension)
$font = 'arial.ttf';
imagettftext($image, $_GET['size'], 15, 50, 200, $white, $font, $_GET['text']);
header("content-type: image/png");
imagepng($image);
imagedestroy($image);
?>
I see funny faces and weird characters on the browser when I call it up. What is wrong this code and what other options available for increasing font size in PHP?
UPDATE After much research on this, I've tried all the suggestions and answers that were given online for this issue, but still it won't display image. I added ./ in front of the font type string. I even uploaded a Microsoft font type from my computer to the server and still ended up with the same result.
UPDATE I did forget to mention that I actually did transfer font type arial.ttf from my computer to the server into the folder where all of my php files resides.