Steal this button generator
Bill Zeller wrote a nice PHP script that uses GD to make 80x15 buttons like the ones found at Steal These Buttons. I downloaded it to so I could make my own buttons quickly on my local machine and the next minute I found myself hacking through the code and modifying it.
The only difference from the outside is that the central bar and the right hand side text now position themselves automatically if no value is given for the corresponding parameters. Under the hood, since I can be pretty maniac when programming sometimes, I grouped all the default values together, I put the code for text drawing into a function and I made it easier to take the parameters from the $_GET
or $_POST
globals in case register_globals is turned off, like on a freshly installed PHP 4.3. I even considered (and wrote some code for) using constants for the dimensions of the image and calculate all the other values, but I decided it was not worth the trouble since the text is bitmapped anyway.
Here is the source.
Update (June 4, 2003): The font must be downloaded on Bill Zeller’s site. font.png should go into a folder named silkscreen next to the PHP script.
Update (February 9, 2004): I forgot to mention it, but Rob found the solution to his problem:
It turns out the problem is that I have an older version of GD, and it doesn’t support imagecreatetruecolor(). I changed the directive to imagecreate(), and it works fine now.
Update (October 11, 2004): font.png is now available here. It should go into a folder named silkscreen next to the PHP script.
Comments
# Much fun, June 4, 2003 at 12:46
hi, i’m right at the beginning of learning php… your source code says:
$letters = imagecreatefrompng( “silkscreen/font.png” );
so, were can i get this “font.png” ??? Seems, that there is something i haven’t understood…
thanks in advance, michael
# Olivier, June 4, 2003 at 14:09
My mistake, I forgot about the font. Since Bill Zeller didn’t explicitely mention whether this one is stealable, I’ll add a link to his site. You should make a folder named silkscreen next to the PHP script and put font.png inside.
# Rob, December 1, 2003 at 22:53
Damn. I’m trying to get your script to work, as I couldn’t get Bill’s to work either. I keep getting the error “The image “http://etc.” cannot be displayed, because it contains errors.”
Any suggestions?
# Greg, February 9, 2004 at 10:07
I get the same error as Rob, same as with the original script…no blank lines at the end of the file, either.
# Greg, February 15, 2004 at 21:51
Just to let you know, my host got everything sorted out and no more errors - turns out PHP got b0rked during a system reinstall, so it seems they recompiled it. Thanks for your help trying to figure out what was up. Your mods work like a charm; it’s nice to not have to figure out the bar and right text position.
# danbee, June 8, 2004 at 17:51
I’m interested in playing around with this script, but I can’t find the ‘font.png’ file anywhere. Any chance you could email it to me?
# Luis, October 6, 2004 at 19:01
Dear Friend
I want to try the button maker script but can’t find the font.png anywhere. can you mail it to me please. Another question? Does your version include an interface??
Regards
Luis
# Olivier, October 11, 2004 at 17:42
font.png can now be downloaded from this site.
# Jeremy, April 26, 2005 at 06:02
I would like to know how to apply a GUI to this so that I can create a button generator with INPUTS. Does anyone know how I would go about doing that?
# Olivier, April 27, 2005 at 20:40
Adam Kalsey made one for the original script. It has clever JavaScript colour palettes.
If you want to make your own, you can start by writing an HTML form with input fields named after the script’s parameters, like here.
The next step would be to make a script that prints the form and displays the image by calling the button script with the new parameters, like Adam did.
# Olivier, April 27, 2005 at 20:43
I need Markdown in comments.
# Signs Of Change, November 27, 2005 at 11:43
http://www.signgenerator.org has a button maker widget ;)
# webdirectory123, December 15, 2008 at 06:35
Hi: How to use the scripts to build a page like this? http://kalsey.com/tools/buttonmaker/
# webdirectory123.com, February 9, 2009 at 14:00
I want to add a buttonmaker to my site http://www.webdirectory123.com/ Where to get the scripts?
# Ölbaum, February 9, 2009 at 14:20
The script is here:Button 0.2.
In order to make a page like you mentioned earlier, you need to write a PHP or CGI that displays the form, and when you submit it generates a page with an img tag whose source is the button PHP script with the parameters taken from the submitted form data. You can also redisplay the form with the last values filled in to make tweaking easier.