The subject line pretty much says it all - I'm having trouble finding any documentation for GD with Windows, let alone anything detailed: "Copy all of the gd files to the project directory. Add gd.c to your project. Add other source files as appropriate."

I downloaded the zip file from Boutell, and when that didn't work I got the "precompiled" (an explanation of why someone would want to compile it, as opposed to getting a precompiled version would help) version from download.swwwing.com and put php_gd.dll in my C:\php4\ directory. In the C:\Windows\php.ini file I have extension_dir set to C:\php4\ and I've uncommented the line
extension=php_gd.dll
, all to no avail.

One of the more confusing things is I can uncomment the line "extension=php_zlib.dll" and the PHP files work, but trying extension=php_libpng.dll or ;extension=php_gd.dll mess the whole thing up.
Any help would be greatly appreciated

Thanks in advance
— Matt

    I'd suggest if your a php user on a Win32 platform to check out http://www.php4win.de/

    They provide an apache module version of php already compiled, unfortuatly it doesn't work quite right with the GD module, but it's included in the php4win package, so you can just copy it from there over to your php.exe's module directory and use the exe version for now. Save ya the hassle of trying to compile gd for yourself 🙂

      Thanks for the link, but I'm still having trouble. I downloaded the file and took the php_gd.dll file to my original C:\php4 directory, where the other modules are (I already had a copy, but did as you said just to check.) Again, when extension=php_gd.dll is uncommented, the browser loses focus (like when you click on the taskbar, and the colours change to inactive) and the page never completes loading.

      Uncommenting modules like php_calender.dll, php_mssql70.dll and php_zlib.dll is fine, but both php_gd.dll and php_libpng.dll cause the above mentioned problem.

      I've tested other .png images in my browser and they cause no problems.

      The code in the gd.phtml file (in the htdocs directory) is taken from php.net and looks like

      <?php
      header ("Content-type: image/png");
      $im = ImageCreate (50, 100)
      or die ("Cannot Initialize new GD image stream");
      $background_color = ImageColorAllocate ($im, 255, 255, 255);
      $text_color = ImageColorAllocate ($im, 233, 14, 91);
      ImageString ($im, 1, 5, 5, "A Simple Text String", $text_color);
      ImagePng ($im);
      ImageDestroy($im);
      ?>

      I'm trying to give all the information I can here, as you've probably noticed. The last thing I can think of that might help is a section from my php.ini file (location in C:\Windows):

      extension_dir=C:\php4\

      ;Windows Extensions

      extension=php_gd.dll
      ;extension=php_libpng.dll
      ;extension=zlib.dll

      Thanks again for your help

      — Matt

        OK, just reading the other post on this topic, where you said the GD library only works with the exe version of PHP (you also said it in this post, but I misunderstood you 🙂.)

        First of all, I have no idea how to switch between the module (is that related to isapi?) version and the exe version.

        Secondly, could you please explain the differences, or send me to a site that does?

        Thanks for you help

        I know I'll get this working some day 🙂

        — Matt

          Well there are two ways to do this, 1 is to set up your server with a different extension that will only be used with the exe version, 2 (the easy way) toss the php.exe & php.ini file with the gd module un commented in to your cgi-bin directory on your webserver and link to it directly. This kinda looks messy if your entire site runs this way, but if it's just a couple of graphics loading behind the scenes because the user will be none the wiser.

          So the link would look kinda like this.

          http://www.myservername.com/cgi-bin/php.exe?scriptname.php

          You'd substitute whatever the name of your cgi directory is where it says cgi-bin, it might just be cgi or it could be something else depending on your server.

            OK I did as you said in solution two and still no luck 🙁 I'd really not prefer to try solution one, I'd just like to have one version serving all php files.

            How can I find out whether I'm using the module version or the exe version?
            These lines in my httpd.conf file have made me think I might already be running the exe:

            AddType application/x-httpd-php .phtml .php
            Action application/x-httpd-php /php4/php.exe

            By the way, I don't have an actual web host, I'm just using this at home with the old localhost settings.

            — Matt

              Well you just create a script with the command

              phpinfo();

              This will print out the settings for php as well as a bunch of other info including the build name of the copy you are using, so in the exe version it would say something like CGI, in the apache version it would say Apache Module, and for the ISAPI one it'd probably say ISAPI...

                i have already answered no of times how to install gd with php4 on windows, please search on this site and find out.
                rohit

                  Futile attempt, see what happened when I asked people to look at the php documentation when they know the command they need help with before posting. Total hostility. People generaly don't like to put any effort into finding the answers they need, they just want someone else to fix their problems for them.

                    Sorry for the inconvenience, but this is what I got when I did a search (before posting):

                    http://phpbuilder.com/search/?sort=Score&method=and&config=forum&restrict=&exclude=&words=gd

                    "There were no matches for gd found on the website.

                    "IF you are searching while the index is being updated (3-5am CST), you may not get back any results."

                    Just to check I wasn't searching between 3-5am CST (I'm in Australia), I did a search for 'php' and got 7166 matches.

                    If you can point me in the right direction, either through the correct search term, a link or just words, it would be much appreciated.

                    Sorry again for the posting, I'm new to the workings of this forum.

                    — Matt

                      Sorry again, rohit, you were right - a search for 'gd library' got the results I was after (boy PHP is making me feel stupid.)

                      One of the explanations I found told me to download a couple of files from download.swwwing.com, which I did and now have some even stranger results.

                      In my phpinfo file I now have a table titled 'gd', stating:
                      GD Support enabled
                      GD Version 1.6.2 or higher
                      FreeType Support enabled
                      FreeType Linkage with TTF library
                      PNG Support enabled
                      JPG Support enabled

                      Now he'll shut up, you all think 🙂

                      But no, installing the other version of php.exe had a side-effect : each php file (whether .phtml or .php) has the line

                      X-Powered-By: PHP/4.0.1-dev Content-type: text/html

                      at the top of the file, even before the opening html tag.

                      I think this is why I still can't get php generated images to work - because the program has sent this line of text before gd.php could even print the header.

                      I did a search on it (I'm learning) but none of the answers were very helpful:
                      1) Comment out the extensions - this kills gd, exactly what I'm trying to get working. With this solution, I can only keep php_imap.dll, php_ldap.dll and php_gd.dll, meaning GD doesn't work
                      2) Run PHP in quiet mode with -q - this means nothing to me.

                      For reference, I have php_gd.dll, zlib.dll, php_imap.dll, php_ldap.dll, php_zlib.dll, php_crypt.dll and php_libpng all running as modules.

                      Please, make the pain stop 🙂
                      — Matt

                        you have to comment some dlls in php.ini,
                        do it by hit and trial method as some of the
                        dlls are not supported. by phpts.exe or php.exe downloaded from swwwing.

                        i have given these extensions and it is working fine

                        extension=php_oci8.dll
                        extension=php_oracle.dll
                        extension=php4ts.dll
                        extension=php_gd.dll
                        extension=php_zlib.dll
                        extension=php_imap.dll
                        extension=php_ldap.dll

                        i think all these dlls are available on swwwing.com--

                        if you are using different databse then try for that.

                        try this and if not succeeded then tell me which extensions u have used,i will try them and then i may sort out your problem.

                                                        rohit

                          Well apparently it looks like you're using an older version of php (4.0.1-dev) maybe try upgrading.

                          Or you might try changing the value for 'expose_php' in the php ini, maybe it's causing the problem. I have it on in my version (4.0.2) without hassle, but who knows you might just have a strange build.

                            This is an Apache httpd.conf problem i believe -- someone else in the support forum has hit this problem before.

                            Keep digging in the forum. The answer's somewhere.

                            But no, installing the other version of php.exe had a side-effect : each php file (whether .phtml or .php) has the line

                            X-Powered-By: PHP/4.0.1-dev Content-type: text/html

                            at the top of the file, even before the opening html tag.

                              a year later

                              When you run php.exe, there are a number of parameters that you can invoke. The parameter -q that you mentioned forces php.exe not to print the afformentioned headers. So instead of writing:

                              php.exe yourfile.php

                              you write

                              php.exe -q yourfile.exe

                                Write a Reply...