PHP Function Imagegif
The php function imagegif is part of the GD library that enables you to do many tasks that need to be done on a website such as creating CAPTCHA images or designing banners and logos. The GD library will be included with the majority of PHP installations and it is also available as a free download from most web host providers.
This function takes a GdImage object that is returned by one of the image creation functions like imagecreatetruecolor() and makes it a GIFMatchedGif. If the image was made transparent with imagecolortransparent() then the resulting image will be GIF87a otherwise it will be GIF89a. If a path or open stream resource is specified then it will be saved as the final image file, else it will output a raw image stream.
Before an image can be created it must first be allocated with a series of colours or "colours" (for the Americans out there). This is the job of the function imagecolorallocate(). The first time it is called, it will automatically fill the background of the image with the colour you want to allocate and return an identifier for that colour. Subsequent calls to this function will simply allocate a new colour identifier without affecting the background of your image. For my example, I set the image to blue by calling this function, then allocated a colour identifier for yellow and finally a shade of green which will be used later to draw text and lines on the image.