Forums Index >> General >> Random image generators...
Page : <1> :
Here is a quick tutorial on making one...
It requires a domain or file hosting thingy that supports PHP scripts... If you have a freewebs, that works just fine...
First, here is the entire script, read on later to find out what it all means...
Mysig.php
<?php
Header("Content-type: image/png");
$randomQuote = randomQuote();
$im = imagecreate(885, 35);
$bg = imagecolorallocate($im, 0, 0, 0);
$textcolor = imagecolorallocate($im, 255, 255, 255);
// write the string at the top left
imagestring($im, 3, 3, 0, $randomQuote, $textcolor);
// output the image
imagejpeg($im);
Function randomQuote()
{
$count = 2;
srand(time());
$random = (rand()%$count);
switch ($random) {
case 0:
$msg = "Hey look! A random message!";
break;
case 1:
$msg = "Another one!!!";
break;
}
Return $msg;
}
?>
Here's what it all means...
Header("Content-type: image/png");
This tells the browser what kind of page we will be visiting... In this case, an image opened like a png file
$randomQuote = randomQuote();
This uses the function at the bottom of the code to pick a random quote
$im = imagecreate(885, 35);
This creates the image, the numbers in the paretheses are the length and width of the image
$bg = imagecolorallocate($im, 0, 0, 0);
$textcolor = imagecolorallocate($im, 255, 255, 255);
This makes the background color and text color, the numbers are RGB values
Imagestring($im, 3, 3, 0, $randomQuote, $textcolor);
This writes the text on the image, the first number is the size, the second and third is the position of the top left corner of our text, randomquote and textcolor are exactly that
imagejpeg($im);
And this actually makes the image when we are all done
I wont go into detail on how the function works because you can get PHP tutorials on the web that teach you these things...
There you go, a quick tutorial on making a php random signature...
Google "PHP tutorials" to get more information
A few extra cool things like counters and such involve more coding....
A good example is below right here! :P
Last edited: Wednesday, November 08, 2006 at 12:09:46 PM
Here's mine. I have it set to change daily. I really need to finish adding in all 100 though... %)
Last edited: Wednesday, November 08, 2006 at 4:39:01 PM
Thank you very much for your most generous response, Warfare. You are very kind man to go out of your way to explain it all! Not to mention a very intelligent one also... :)
I do believe I'll be needing to read up on this stuff. Ain't your regular "piece of cake". :'(
/¯/¯/ed
Last edited: Wednesday, November 08, 2006 at 5:46:44 PM
^PHP isn't hard at all... You should try Java or C++ lol
My sig reads from a.txt file in my server... Slightly different from warfare's :)
The second one (View counter) writes a number to a.txt every time it's seen, replacing the old number that was on the file :)
It also shows the new number.
^ java is a pain in the arse....it whines at every little error... I dont understand why my school decided to teach it over C++.... Oh well....
C++ is much better.... At least my programming class is one I can goof off in :P
Last edited: Monday, November 13, 2006 at 9:30:32 PM
^ Yea I know, just that comparing PHP to Java or C++ in wich ones are harder, is like comparing an ant to an elephant in size.
Page : <1> :
Hey, I was wondering where I could get one. I've seen them in action in a few of the user's sigs around here. I've Googled it but didn't come up with what I wanted. I wouldn't be using it around here, but possibly on my web page. If anyone could help me out ot direct me to a site that explains how to make one, I'd much appreciate it. Then again, if you don't feel like sharing, that's also understandable. Feel free to also contact me at fighter_ace_bomb(at)yahoo.com. Thanks!