[eluser]Alhazred[/eluser]
I have to dynamically write some texts on an image and show it on the page.
I've put the image into a folder "static/images" and the font file into a folder "static/fonts" and to make a try I've written this function into a controller
Code:
public function write_img()
{
header('Content-type: image/png');
$png_image = imagecreatefrompng(base_url('static/images/calendar-icon.png'));
$white = imagecolorallocate($png_image, 68, 68, 68);
$font_path = base_url('static/fonts/arial.ttf');
$text = "25";
imagettftext($png_image, 25, 0, 75, 300, $white, $font_path, $text);
imagepng($png_image);
imagedestroy($png_image);
}
The problem is that the image is not shown on the page.
Firefox says that the image contains errors, Chrome and Opera show the "image not fond" icon, Safari shows a blank page, Internet Explorer says:
<p>Severity: Warning</p>
<p>Message: imagettftext(): Invalid font filename</p>
<p>Filename: controllers/home.php</p>
<p>Line Number: 83</p>
</div>‰PNG
and follows a text which looks the content of an image file opend on a text editor.
As IE says it seem that the font file is invalid, but what does that mean? The file is there.