Please, use the following PURL, if you wish to link to this guide:
- Browser Requirements.
- Server Requirements.
- About GD Fonts.
- Folder Structure.
- Apache configuration.
- Uploading basic resources.
- Creating your first dynamic signature.
- Creating a random signature (text).
- Creating a random signature (images).
- Last Message Posted sample.
- Latest Drupal Nodes.
- Final notes.
This tutorial just shows you one of lots of possible implementations to create dynamic signatures. A dynamic signature is a banner image which is dynamically generated by a small script. So you can use a default background image and write over it any information. The limit is your own imagination.
Actually, I'm going to explain how I implemented mine and post the resources I used. As I believe it might be useful to share the basics. I hope you learn something, as well as I did, sometime ago. ;)
The samples described here use a GIF image for the background and generate a PNG image using GD functions present in almost all PHP installations. So, if you need another approach, you should change the relevant pieces in the code itself to adapt the samples to your own needs.
You could also generate images with other formats: JPG or even GIF(*).
Note (*): GIF patent expired worldwide July, 7th 2004. :P ...GD support for creating GIF images was enabled with GD library version 2.0.28. Read about it here.
« top »
All the material described in this tutorial is meant to be used on Apache, which is what I know of. So, please, don't ask me about other webservers, I can't help you. ;)
GD support (not sure about the version, though). The tutorial makes use of the following image related functions: getimagesize, imagecreatefromgif, imagecolorallocate, imageloadfont, imagestring, imagepng and imagedestroy.
« top »
GD library in PHP already provides several built-in fonts. They use IDs from 1 to 5.
However, you could also create your own fonts. Check out the following resources to learn more about it:
They also provide a nice gallery of GD Fonts for PHP imageloadfont().
All credits should go to them. I learnt a lot reading their guide. Thanks! :-)
Though, I have uploaded several GD fonts to this site, just as a "safe resource" (please, use it only if their link fails).
« top »
Create the following folder structure:
« top »
Upload a .htaccess file to the webroot/sig folder with the following contents:
This tells Apache to process PNG files as PHP scripts. So, you can generate dynamic images based on PHP code and still use valid PNG images to post wherever you need. No one will notice they are, in fact, PHP files. ;)
Upload a .htaccess file to the webroot/sig/gd_fonts, webroot/sig/includes and webroot/sig/images folders, with the following contents:
<Limit GET POST HEAD PUT DELETE>
deny from all
This will prevent direct HTTP access to the files on these folders. So, anyone trying to do so, will (hopefully) get a nice 403 HTTP error.
« top »