Page 1 of 1

imagettftext(), imagefttext() work, imagestring() not

Posted: Fri Sep 04, 2009 1:00 pm
by sousousou
First I used imagestring() as a function

imagestring($im, 5, $x, $y, $text, $black); and this worked. The only problem is that the fontsize won't get any bigger than this 5 which still is almost unreadable.

So I searched the internet for some solutions. The solutions I found are the functions imagettftext() and imagefttext() which have a fontfile parameter.

My code for this is

Code: Select all

 
$font = 'arial.ttf';
 
imagefttext($im, 20, 0, 11, 21, $white, $font, $text);
 
This won't work. The 3 imagestring() texts are still printed in the image while this imagefttext (or imagettftext) isn't.

Re: imagettftext(), imagefttext() work, imagestring() not

Posted: Fri Sep 04, 2009 3:01 pm
by sousousou
Hmm, there's an error in the topictitle, the first 2 don't work, imagestring() does.

Re: imagettftext(), imagefttext() work, imagestring() not

Posted: Mon Sep 07, 2009 7:39 am
by sousousou
Ok I found the error in it. When I have one file and the font in the same directory it works. The problem was that this was only a testcase to see if I can get the imagettftext to work.

In my website I use a different kind of structure with which it doesn't work.

I use a form file in which I call <img width="150" height="100" border="0" src="php/image.php" alt=”secImage”> <br />.

Image.php on it's turn uses the function createImage which it includes from a functions.php file.

In functions.php I try to use the code above as a function and when I say $font = 'fonts/arial.ttf'; it doesn't work anymore.

De directory structure is

Code: Select all

index.php (which includes form.php)
 /php
   form.php
   image.php
   /formfunctions
     functions.php
     /fonts
       arial.ttf