Actually this isn't created by me but by a friend of mine, so i think it may be usefull..
PHP Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
header("Content-type: image/gif"); // We have to set the header of the file as its an image
$text = @$_GET['text']; // Get the text to write
// The $_GET function grabs the data specified by the ?text parameter on the URL
$font = 'Volter.ttf'; // Set the TTF font we want to use
// This is just a variable set, which we will later use in the imagettftext funciton
$fontsize = "6.5"; // Set the size of the font we want to use
// This again is just a variable like above.
// Create the image
$size = imagettfbbox($fontsize, 0, $font, $text); // Set the positions of the area of the font
$width = $size[2] + $size[0] + 8;
$height = abs($size[1]) + abs($size[7]); // Get values
// We have the right sizes for the text
$im = imagecreate($width, $height);
// Create the image of the right size for the text to fit
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255); // Create the colour white using RGB
$black = imagecolorallocate($im, 0, 0, 0); // Create the colour black using RGB
# The imagecolorallocate uses RGB colours to allocate an individual colour to a string. EG/ $white.
// Make a colour transparent
$colourBlack = imagecolorallocate($im, 255, 255, 255); // Set colour black using RBG
imagecolortransparent($im, $colourBlack); // Make colour black transparent
# imagecolortransparent makes the pre-made string which has been allocated a colour transparent on the image.
// Add the text
imagefttext($im, $fontsize, 0, 0, abs($size[5]), $black, $font, $text);
# imagettftext writes the text to the image, the different stages of the funciton are explain below the php code (from php.net)
imagegif($im); // Output the image using imagegif()
imagedestroy($im); // Delete the image to keep server load down
?>