I am working on a PHP button generator.
There will be a selection of buttons (images) and fonts. Users will be able to create an image button.
I would like to make the button image stretch to match the length of the text string... or to at be length adjustable by the user.
So far this works without the stretch:
http://www.createbutton.com/buttonmaker.html
Here is the PHP thus far:
The HTML is:PHP Code:<?php
// Set the content-type
header('Content-type: image/png');
// Create the image
$im = imagecreatefrompng("images/button1.png");
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
// The text to draw
$text = $_POST['label'];
// Replace path by your own font path
$font = 'fonts/arial.ttf';
// Add some shadow to the text
imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);
// Add the text
imagettftext($im, 20, 0, 10, 20, $white, $font, $text);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>
HTML Code:<form name="form1" method="post" action="buttonmaker.php"> <input type="text" name="label" title="Enter your text here" style="font-size:16px; color:#0000FF; text-decoration:none;" value="Your text here" onfocus="if(this.value=='Your text here'){this.value=''};" onblur="if(this.value==''){this.value='Your text here'};" size="25" class="textbox"> <input type="submit" value="Generate Button" /> </form> I'm thinking that the best solution would be to use three images... a left side of the button with rounded edges, a center that is stretchable, a right side with rounded edges. The left and right side images will not stretch. Any ideas?


Reply With Quote
Bookmarks