PHP GD problems - Can't solve


9 posts
by BakaOsaka » Thu Jul 05, 2012 5:38 pm
Hello all.

I have GD installed on my Debian server (sudo apt-get install php5-gd) and it loads images fine, but whenever I try to use a ttf on it, the text doesn't show at all.

Can someone offer me some help?

Code: Select all
array ( 'GD Version' => '2.0', 'FreeType Support' => true, 'FreeType Linkage' => 'with freetype', 'T1Lib Support' => true, 'GIF Read Support' => true, 'GIF Create Support' => true, 'JPEG Support' => true, 'PNG Support' => true, 'WBMP Support' => true, 'XPM Support' => false, 'XBM Support' => false, 'JIS-mapped Japanese Font Support' => false, )imagejpeg: true
imagecreatetruecolor: true
imagedestroy: true
imagecolorallocate: true
imagefilledrectangle: true
imagecolorat: true
imagesetpixel: true
imageline: true
imagefontwidth: true
imagettfbbox: true
imagestring: true
imagettftext: true


That's the output of a php test, and shows I have ttf enabled.

Code: Select all
gd
GD Support    enabled
GD Version    2.0
FreeType Support    enabled
FreeType Linkage    with freetype
FreeType Version    2.4.2
T1Lib Support    enabled
GIF Read Support    enabled
GIF Create Support    enabled
JPEG Support    enabled
libJPEG Version    6b
PNG Support    enabled
libPNG Version    1.2.44
WBMP Support    enabled

That's the output of phpinfo.
User avatar
Posts: 40
Joined: Tue Jun 12, 2012 11:30 am
by empire » Thu Jul 05, 2012 11:36 pm
Try running this command too:
sudo apt-get install libgd2-xpm
http://rpi-blog.com - Raspberry Pi guides, tips, tricks, and resources :-)
Posts: 42
Joined: Thu Jun 14, 2012 2:00 pm
by BakaOsaka » Fri Jul 06, 2012 9:32 am
Seems as if it's already installed.

Code: Select all
pi@raspberrypi:~$ sudo apt-get install libgd2-xpm
Reading package lists... Done
Building dependency tree
Reading state information... Done
libgd2-xpm is already the newest version.
libgd2-xpm set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 45 not upgraded.


More info:

Code: Select all
pi@raspberrypi:~$ php5 -i | grep -i --color gd
Additional .ini files parsed => /etc/php5/cli/conf.d/gd.ini,
gd
GD Support => enabled
GD Version => 2.0
gd.jpeg_ignore_warning => 0 => 0
User avatar
Posts: 40
Joined: Tue Jun 12, 2012 11:30 am
by Pirx-Danford » Fri Jul 06, 2012 10:05 am
Does PHP show any errors?

If not maybe do

ini_set ( 'display_errors' , '1' );
error_reporting ( 'E_ALL' );

at the start of the script.
Posts: 62
Joined: Thu Oct 06, 2011 2:05 pm
by BakaOsaka » Fri Jul 06, 2012 10:46 am
Oh what? I chmod 755'd all the files in the directory and it seems to work now! Thanks for the help :D
User avatar
Posts: 40
Joined: Tue Jun 12, 2012 11:30 am
by exe888 » Thu Jan 10, 2013 7:41 am
I am having this exact ptoblem too...
you chmodded the files in which directory exactly??

(linux newbie)
Posts: 10
Joined: Wed Nov 07, 2012 7:51 pm
by exe888 » Thu Jan 10, 2013 7:42 am
I am having this exact ptoblem too...
you chmodded the files in which directory exactly??

(linux newbie)
Posts: 10
Joined: Wed Nov 07, 2012 7:51 pm
by MyRevel » Mon Mar 04, 2013 6:23 pm
I had the same problem.
My problem was solved after adding the php code:
// Set the enviroment variable for GD
putenv('GDFONTPATH=' . realpath('.'));
I found this solution in the description of the imagettftext(), see http://www.php.net/manual/en/function.imagettftext.php
Posts: 3
Joined: Mon Mar 04, 2013 6:04 pm
by RootShell » Mon Mar 25, 2013 11:54 pm
You could also copy the used font to the same directory as the php file :)
Posts: 3
Joined: Fri Mar 22, 2013 10:35 pm
Location: Albufeira / Portugal