An Intro to Using the GD Image Library with PHP - And Even More Functions
(Page 4 of 6 )
int ImageColorTransparent (int im [, int col]) |
With this function, we can set the transparency color of an image or find out what the current transparency color is. If all we pass this function is a pointer to an image, we will be returned the identifier of the current transparency color. If we pass it a image identifier and a color, that color will be set to transparent for the image.
array ImageTTFText (int im, int size, int angle, int x, int y, int col, string fontfile, string text) |
Ok, so we can draw all these boxes and circles and things, but how do we put text in our image? ImageTTFText is one of the ways to do so. It's actually pretty simple, but can take a little experimenting to get your text positioned right where you want it. You pass this function a image identifier, the size of the font, the angle (standard left to right reading would be an angle of 0, 90 degrees would result in text going from bottom to top.), a starting point signified by x and y, a color, the font to use and the string to display.
Of special note here is that the starting point for this function is at the lower left corner of the text, NOT the upper left. Be careful of that or your text will not be where you want it. Also, you need to provide the path to the font you want to use, here's a link to the arial font that I use in this tutorial.
int ImagePNG (int im [, string filename]) |
This is the function that we will use to actually display this image. All the other functions up until this point have just been manipulating the image in memory. This one will send the binary stream out so that we can see it. We could specify a filename to write the image to, but we aren't going to do that here.
Next: Putting It All Together >>
More Miscellaneous Articles
More By Matt Wade