|
||||||
| PHP Tutorials PHP Tutorials |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||||
|
Title: Create dynamic userbars with GD
Introduction: Have you ever been on aim and received a message from one of your friends with a big long URL followed by something like "John%20Is%20Stupid." You know what ever it is, wont be worth your time, but you click on it anyway to find someone goofy looking holding a sign and on it printed in big bold letters “John Is Stupid.” Ever wonder how they work? Chances are the script takes advantage of the GD functions. In this tutorial you will learn many GD functions that you can use to generate images. The goal for this tutorial is for you to generate a dynamic user bar like the one below. Extreme Development - Home Here is a list of the functions used in this tutorial: header() imagecolorallocate() imagettfbbox() imagesx() abs() imagettftext() imagepng() imagedestroy() Solution: The first thing you want to do is create the header type using the header function. Next you use the GD tools to create an image from a png file. In my case, I have userbar.png in the same directory as this script is in. The function imagecolorallocate creates a color using RGB (red-green-blue) format. The next three lines just set some basic information which isn’t that hard to understand. The last three lines to must of the work creating the image. The most important function here to pay attention to is imagettftext. The imagettftext requires 8 arguments which are the resource image, font size, the angle, x location, y location, font color, the actual font, and the string to be printed. PHP Code:
PHP Code:
PHP Code:
PHP Code:
PHP Code:
Code:
<img src="http://www.yourdomain.com/generator.php?text=JUNKIE" /> Last edited by John; 11-08-2007 at 02:16 AM. |
| Sponsored Links |
|
|
|
|||||
|
Nice Tutorial, very well done.
__________________
CodeCall Blog | CodeCall Wiki | Shareware Site | Linux Forum | Write a Blog Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall |
|
|||||
|
:0 Im impressed
I wish I knew PHP
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall ![]() Business Directory | Technology Blog | Windows Help |
|
|||||
|
I have a problem with the 1st tutorial.. I made this:-
Code:
<html> <img src="http://localhost/generator.php?text=ADMINISTRATOR" /> </html> I even tried to upload it to a hosting site that supports php.. still broken link...
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall ![]() Business Directory | Technology Blog | Windows Help Last edited by TcM; 12-04-2006 at 11:54 PM. |
|
|||||
|
I'm betting you do not have GD working or compiled into your system. Is it a Windows System?
Create a PHP file named phpinfo.php and put this in it: PHP Code:
__________________
CodeCall Blog | CodeCall Wiki | Shareware Site | Linux Forum | Write a Blog Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall |