I want to start getting into PHP image manipulation. I'm running PHP 4.0.4 w/ Apache under Windows, and I tried this script and got an error saying I had an undefined function:

<?php
//Send the header, so browser expects a gif

Header("Content-Type: image/gif");

//Create a new image- 100x100 pixels

$im = ImageCreate(100, 100);

//allocate colors to the image

$black = ImageColorAllocate($im, 0, 0, 0); //background color
$white = ImageColorAllocate($im, 255, 255, 255);

//draw line from uppper left to bottom right hand corner

ImageLine($im, 0, 0, 99, 99, $white);

//Send Image to browser

ImageGif($im);

//Destroy image

ImageDestroy($im);

?>

I guess I don't have the GD Library etc. installed- how do I do this w/ windows- and where do I get the files I need?

thanks for your time.

    The GD Library is part of the standard distribution from php.net. All you should have to do is uncomment the "extension=php_gd.dll" line in php.ini. This will give you JPEG and PNG support. If you want GIF support try looking at you'll have to do some searching. I used to know where to get it...... but the old memory is failingπŸ™‚ Also, if you're running IIS you'll need to get PHP 4.0.4 or higher. I've experienced weird warning messages on that server which can't be suppressed with lower versions. Hope this helps!!!

    Cheers,

    Geoff A. Virgo

      Hi,
      can you also tell me what option to use with apache ?

      thx

        I'm not sure what you mean by "what options to use with Apache". Are you trying to compile a version of the GD library for Apache on Windows?

          I uncommented "extension=php_gd.dll" in php.ini, but when i start up apache I get this error: "Unable to load dynamic library './php_gd.dll' One of the library files needed to run this application cannot be found."

          Any suggestions? Thanks a lot for your help- your previous comment got me on the right track πŸ™‚

            This is going to sound like a dumbass suggestion, but have you specified the path to your extension folder in the extension_dir directive in php.ini? An invalid path is the usual cause of the error message you mentioned. If you already have specified that directive, have you downloaded the most recent PHP distribution? I also seem to recall reading somewhere that the GD module will not work on Win32 if PHP is being run as a CGI process, rather it needs to be loaded into the server as a module. If this is the case, and you need help setting PHP up as a module contact me and I'll try to help you through it (PHP can sometimes be a pain to get running as a module on Win32πŸ™‚ Hope this helps!!!!

            Cheers,

            Geoff A. Virgo

              Please

              1. refer to the INSTALL and README of PHP 4.0.4, for the instructions of running PHP as a module or CGI process of Apache;

              2. modify your php.ini as follows:

                a. extension_dir = <the absolute path for your php extensions, e. g. c:\php4\extensions>

                b. extensions = php_gd.dll

                Got it working- thanks again for your help πŸ™‚

                  Write a Reply...