I have been looking around the internet when I first started making these, and I really never could find a good one that was easy for the beginner.
libraryofmike is the best one that I have found so far, it gets to the basic, so you can progress from there.
I am not going to go into big detail here since it would be a lot to cover, but I'll go over the basics.
--------------------------------------------------------------------
we start with the variable that we are going to call this image, lets say
from there we can either call in another picture that we will superimpose onto, or make a new one
PHP Code:
//New One
$image = imagecreatetruecolor(200, 200);
//(w x h)
//Call in another picture
$image = imagecreatefrompng("picture.png");
//imagecreatefrompng, can be switch to jpg, gif, and some other check PHP.NET for others
For colors GD does not allow us to use Hexadecimal values, so we have to convert them to RGB, http://www.kenjikojima.com/java/RGBHexConverter2.html
I like to place my colors in a variable so it is easier to reference than placing imagecolorallocate($image, 255, 255, 255); for white
PHP Code:
$white = imagecolorallocate($image, 255, 255, 255);
for the font, I also like to refer to them as a variable, but make sure you have the correct directory, otherwise it doesn't work
PHP Code:
$font = 'yourfont.ttf';
now for the fun part, adding in text
we will use the imagettftext fuction, the syntax is as follows:
PHP Code:
imagettftext(image, size, angle, x, y, color, font, "text");
//image - the image you are to draw on
//size - the size of the text (points)
//angle - what angle you would like the text to display at
//x - x-coordinate
//y - y-coordinate
//color - the color you would like the text to be (this case $white)
//font - the font you would like the text to be (this case $font)
//text - the text you would like to display
now after all that is settled, we need to tell the browser to display this as a png, rather than php; or any other picture file
PHP Code:
header("Content-type: image/png");
//tells the browser it is a png picture
imagepng($image);
//displays the png image "image"
imagedestroy($image);
//removes the image from memory
hope it is easier for you guys to understand