GD2 Library Binding
What is GD2 for?
GD2 is a module binding LibGD, which is meant for offline/batch image manipulation. In short, it allows to deal with a set of very common image file formats, manipulate them and save them. Integrating it in a web server (i.e. through the Falcon Apache2 module), you can create server-side dynamic image generators, as in the following example:
This is a PNG image dynamically generated through a server-side FTD script:<? load gd2 Reply.ctype("image/png") img = GdImage( 200, 200 ) blue = img.ColorAllocate( 10, 10, 90 ) white = img.ColorAllocate( 0xff, 0xff, 0xff ) font = gdFontGetMediumBold() for i = 1 to 10 img.String( font, 5, i * 15 + 2, "Hello " + i + " times.", white ) end out = stdOut() img.Png( out ) ?>
Index
The ability to create graphs from server data (i.e. DB entries) on the fly is quite precious, even when different techniques to generate graphics at the client site are now becoming common.
- Building - Building the module from source.
- Documentation - Usage and warnings. === Some Samples
- gd_load.fal.txt - Loading an image.
- gd_save.fal.txt - Loading an image and saving as a different format.
- gd_drawing.fal.txt - Drawing some figures.
- gd_string.fal.txt - Writing graphic through builtin fonts.
- gd_stringft.fal.txt - Writing graphic text through TTF fonts.