The bundled extension offer a lot of functionality. I have spent a lot of time how to compile extension for my version of PHP. So there are instructions.
Another way:
Also I could compile a module with the following parameters:
#! /bin/sh
#
# Created by configure
'./configure' \
'--with-php-config=/usr/bin/php-config' \
'--with-gd=shared' \
'--with-freetype-dir=/usr' \
'--with-vpx-dir=/usr' \
'--with-jpeg-dir=/usr' \
'--with-xpm-dir=/usr' \
'--with-png-dir=/usr' \
'--with-t1lib=/usr' \
'--enable-gd-native-ttf' \
"$@"