I know that a lot of people have had this problem, so to start, I've tried all of the following:

On Windows Server 2003, with PHP 5 loaded with ISAPI module -

Removed the semicolon in php.ini extensions list for php_gd2.dll
Verified that php_gd2.dll is in the correct directory
Verified that the php.ini is pointed to the correct extensions directory
Verified through php_info() that it's looking at the correct php.ini
Attempted to fix problem by placing php_gd2.dll in C:\PHP
Attempted to fix problem by placing php_gd2.dll in C:\WINDOWS and C:\WINDOWS\SYSTEM32
Added C:\PHP\ext to environment paths
Restarted the server countless times
Verified correct security settings for internet guest accounts, etc.

PHP itself runs just fine, but the GD library, which is an absolute requirement for our company's site, will not load. It doesn't show up in the php_info() display and any calls to GD functions throw errors.

I've scoured multiple forums and websites, and tried every 'fix' I've seen, with no luck.

If anyone has any idea as to what the problem is, I would greatly appreciate any help. I won't lie, I'm desperate for an answer.

    by doing phpinfo(): what is your extension path?

    where is php .ini located?

    things i found:

    well the solution was that I had my php.ini file in windows\system32 and not c:\php...

    when I moved my php.ini file the changes took and GD looks to be installed.. Thank you both

    I had a similar problem. Under Windows XP, I have php.ini in the windows directory. I simply changed the path of the extension library in php.ini from:
    extension_dir = "c:\php"
    to:
    extension_dir = "c:\php\extensions"

      php.ini is in C:\PHP, and php_info() correctly points to it. My extensions folder is the default - \ext - and the .ini file correctly points to it. I've also tried adding a trailing slash - \ext\ - as suggested by one poster in a different forum, which didn't resolve the issue.

        are other extensions loading properly?

        are there any special permissions on these folders set by the win32 system

          Is display_errors set to on? Have you tried turning on "display_startup_errors" and restarting your webserver to see if you get any messages?

            8 days later

            I think you installed from the MSI file - I did, and it didnt work. Neither did the non threadsave PECL version. However when I downloaded the full zip file and copied the php_gd2.dll from there (it is 4k smaller than the version in PECL - has someone forgotten to do a binary copy?), GD sprang into life! However EXIF is still broken.... sniff

              HA sorted that one too. php_mbstring.dll is loaded after php_exif.dll by the installer. Change the order in php.ini and hey presto, exif loads too....

                2 years later

                I had the same problem and in spite of doing all steps in the configuration file, the problem persisted. However, i went to http://snaps.php.net/win32/ and downloaded the full zip file (php5.2-win32-latest.zip 9,943,602 bytes) containing the binaries. Extracted them to a folder. The GD library (php_gd2.dll) in this archive was 5 bytes smaller than the one in "php-5.2.6-Win32.zip" (9,744,616 bytes) downloaded from http://us2.php.net/downloads.php . Once, the existing library was replaced with the new one, i was able see that, GD library was loaded. I used the following script to verify the same.

                echo '<pre>';

                if ( extension_loaded('gd') )
                {
                	echo 'GD2 is loaded', PHP_EOL;
                	echo '--------------', PHP_EOL;
                
                	foreach ( array_shift(get_defined_functions()) as $function )
                	{
                		if ( preg_match('/^image.*jpeg/i',function) )                 

                echo $function, PHP_EOL;
                }
                }
                else
                {
                echo 'GD2 is not loaded';
                }
                echo '</pre>';

                  8 days later

                  The library file's properties will give the version number for the library; the php_*.dll files' version numbers should be the same as that of php.exe itself (currently 5.2.6.6).

                    21 days later

                    I copied Mathimulgil's gd-verification script into a blank text document (in between <? ?>, of course), called it "gdinfo.php", transferred it to my server and ran it. the result was:

                    Parse error: syntax error, unexpected T_FUNCTION in /homepages/26/ ... /public_html/gdinfo.php on line 11

                    Line 11 - 13:
                    if ( preg_match('/image.*jpeg/i',function) )
                    echo $function, PHP_EOL;
                    }

                    Given that gd seems to work on the server in question, and that I am an ignorant code mangler who learns by doing, what should I have done in order to use the script successfully?

                    This matters. I'm having real problems installing an application I 'wrote' on a client's server, and I need to verify that gd works on his server. I get the same error message on his server as I do on mine, but that's probably not enough verification that his works, too, is it?

                    I hope someone can clear this up for me.

                    Thanks,
                    - Paul

                      Here's a one-liner to check if GD is installed:

                      echo 'GD is ' . (function_exists('gd_info') ? '' : 'NOT ') . 'installed!';

                      For more information about detecting what capabilities the installed GD library has, see the manual page for [man]gd_info/man.

                        And as the manual suggested, <? var_dump(gd_info());?> showed me the multilinear goods:
                        'array(12) { ["GD Version"]=> string(27) "bundled (2.0.34 compatible)" ["FreeType Support"]=> bool(true) ["FreeType Linkage"]=> string(13) "with freetype" ["T1Lib Support"]=> bool(true) ["GIF Read Support"]=> bool(true) ["GIF Create Support"]=> bool(true) ["JPG Support"]=> bool(true) ["PNG Support"]=> bool(true) ["WBMP Support"]=> bool(true) ["XPM Support"]=> bool(false) ["XBM Support"]=> bool(true) ["JIS-mapped Japanese Font Support"]=> bool(false) } '

                        Appears to be the whole nine yards...

                        Thanks, bradgrafelman.

                          8 days later

                          For what it's worth, mathimugil's code has a typo (one reason why cut-and-paste code never works): line 11 should have read

                          if ( preg_match('/image.*jpeg/i', $function) )

                            I just tried installing on my Windows XP SP 2 box and I didn't have any problems with GD being installed. phpinfo() shows it installed fine. You shouldn't have to do anything you mentioned in your post to move files around, change paths, remove semicolons in the INI or anything like that.

                            I downloaded .MSI Apache 2.2.x and installed everything. I then downloaded PHP 5.2.8 installer and installed everything. I didnt have to touch httpd.conf nor php.ini to get any of this to work (except for adding AddType to httpd.conf).

                            I chose c:/php as my php installation directory. I chose c:/apache as my apache directory.

                            Start over from scratch. Uninstall Apache and PHP off your computer. Then, go and remove anything leftover in the directories. Do a complete scrub.

                            Next, do a search for GD and any other DLLs that you may have copied to anything in the PATH or in Windows/Windows32. Remove all those DLLs if there are any.

                            Then, install Apache first, then PHP.

                            You probably have some sort of DLL conflict going on and interrelationships between them of the wrong versions.

                              a year later

                              Solved (for me at least): Too many rogue php.ini files...

                              I had been trying to install all kinds of php versions for my Win XP. NOTHING worked. Because of this I had php.ini files in C:\Windows and C:\php5

                              I noticed that in my phpinfo.php files showed:
                              Configuration File (php.ini) Path C:\WINDOWS
                              Loaded Configuration File C:\php5\php.ini

                              When I deleted these two files--AND STOPPED and then STARTED my services--my gd2.dll FINALLY started working.

                              I hope this helps!

                              Joel

                              Oh, when I tried using a gd2.dll from a different php installation, i got filesize original compiler errors...

                                Write a Reply...