Hi all,
I just started learning php and have so many questions to ask.
Such as how to create image in php?
I already try to use imagecreate() this function and imagegif(), but still there exists errors when i link to the php file.
<?php
header ("Content-type: image/gif");
$image = imagecreate( 200, 200 );
imagegif($image);
?>

Is there any connection with GD function? If so, how should i make these gd functions work while i'm creating images in php?

By the way, would u mind helping me in explaining what and how header works in php program.

Thanks so much 🙂
Have a nice day

    Don't use gif unless you have an old version of GD (I doubt it) use png instead. heres a simple example:

    <?php 
    header("Content-type: image/png"); 
    $image = imagecreate( 200, 200 ); 
    imagecolorallocate($image,200,100,100);
    imagepng($image);
    imagedestroy($image);
    ?>

    dont forget to free the memory of the image at the end with imagedestroy or you'll regret it.

    theres a whole section on images in the PHP Manual

      are there any workarounds and/or other ways to resize gifs? i started using the gd lib. just a few months ago on my own page and had to "downgrade it", requiring users to use jpgs from now on.

      is it correct, that the removal of the gif fcts. in the gd lib are due to copyright issues?

        it still can't work 🙁
        the error message
        Warning: Cannot add header information - headers already sent by (output started at c:\phpWeb\color.php:3) in c:\phpWeb\color.php on line 4

        Fatal error: Call to undefined function: imagecreate() in c:\phpWeb\color.php on line 5

        help me please
        should i download any addtional software?
        so far, i just use php 4, apache 2 and mysq
        thanks 🙂

          are you sure you have GD installed?

          a phpinfo check should give you the info. run this script:

          <?php
          phpinfo();
          ?>

            thanks so much for your help guys
            i just realized that I haven't changed the extension_dir in php.ini
            although i have installed gd. 😉

              i still have the same problem though
              now the problem is that the graph won't appear at all eventhough i already change extension_dir in php ini to the directory where the gd dll located.
              I really do not know what's the problem.
              Maybe there are some stuffs i need to change again?
              Cheers 🙂

                Write a Reply...