PHP have mosts of functions available to create a image on the fly. You can use these functions to create a captcha image or a add banner on the fly.

<?php
$new_image = imagecreate( 400, 200 );
$apply_background = imagecolorallocate( $my_img, 0, 0, 255 );
$text_colour = imagecolorallocate( $new_image, 255, 255, 0 );
$line_colour = imagecolorallocate( $new_image, 128, 255, 0 );
imagestring( $new_image, 4, 30, 25, "Text Displayed in Captcha",
$text_colour );
imagesetthickness ( $new_image, 5 );
imageline( $new_image, 30, 45, 165, 45, $line_colour );
header( "Content-type: image/jpeg" );
imagejpeg( $new_image );
imagecolordeallocate( $line_color );
imagecolordeallocate( $text_color );
imagecolordeallocate( $background );
imagedestroy( $new_image );?>

Create Image

Create image using the PHP function createimage(), function will create image with the dimensions of the image, namely its width and height in that order

Apply Colors

Next thing is to apply colors using the imagecolorallocate() function.
Colours are allocated using the imagecolorallocate() function. This function will automatically fill the background of the image with the colours you specified, and return an identifier for that particular colour. Subsequent calls to imagecolorallocate() will create a colour identifier for your colour.
imagecolorallocate() returns FALSE if the function fails for any reason.

Write Text On Image

We can write text on images using the function imagestring().
imagestring ( resource $image , int $font , int $x , int $y , string $string , int $color );
1] $image is image source
2] Font Can be 1, 2, 3, 4, 5 for built-in fonts in latin2 encoding
3] x-coordinate of the upper left corner.
4] y-coordinate of the upper left corner.
5] The string to be written.
6] A color identifier created with imagecolorallocate().

Display Image

Image is created using imagejpeg()
In this example i passed header( “Content-type: image/jpeg” ) as i want to create a jpg image.
Other functions are
1]imagepng()
2]imagegif()

Free Resources

Free individual resources which are created using the imagecolordeallocate() function and the image resource using the imagedestroy() function.