Make sure your ./configure line for PHP contains
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-apache2 --with-jpeg-dir=/home/stefan/jpeglib --with-png-dir=/home/stefan/pnglib --with-tiff-dir=/home/stefan/tiff --with-freetype-dir=/home/stefan/freetype-2.1.10 --with-gd
when compiling PHP.
This should insure that GD will be picked up in PHP, and that its full range of graphics formats will be supported. (Of course, you'll need to provide your own jpeglib, pnglig and tiff libs, as well as your own freetype location - those given above are only valid on my system, where I installed them myself.)