Posts Tagged ‘gd’

imagettftext only displays yellow text

9. May 2009

No Comments »

Lately I have been doing some work with the PHP GD library. I wanted to put text on an image so I naturally used imagettftext(). I started by copying the example code provided by the manual and intended on modifying the code to fit my needs. When I executed the code my my browser, the text was yellow. I took a look at the code, and the results did not match. The text should have been black. I tried adjusting the imagecolorallocate parameters to reflect a different color. However, this time with I executed the code, no text showed up. It turns out I needed configure PHP –with-freetype-dir. After a recompile with the new configuration it worked fine.

./configure \
–disable-magic-quotes \
–enable-bcmath \
–enable-sockets \
–with-mysq=/usr/local \
–with-apxs2=/usr/local/apache2/bin/apxs \
–with-curl \
–with-gd \
–with-freetype-dir=/usr
–with-png \
–with-jpeg \
–with-ttf

text1