First, you don't need both gd and gd2. Comment out the first one and just use gd2. Then change your php.ini file:
Windows
; Directory in which the loadable extensions (modules) reside.
extension_dir = c:\php\extensions\
Unix
; Directory in which the loadable extensions (modules) reside.
extension_dir = /path/to/entensions/