I am working on a button generator for web designers.
I have a generator that puts text on a glossy button quite nicely. There are two more things I would like it to do:
1.) Support transparency (I have a script that does this, but cannot get it to work with the text)
2.) Resize the image and text (I also have a resize script, but again cannot get it to work with the text overlay).
Any ideas? Suggestions?
Here is the working script in action on the unfinished page:
[url]http://www.createbutton.com/glossy-buttons/
Here is the PHP code for the ‘engraved’ button:
[code=php]
<?php
// Set the content-type
header(‘Content-type: image/png’);
//Select background image
$buttonbg = $_POST[‘logo’];
$indent = $_POST[‘indent’];
$shadowindent = $indent + 1;
$reflectindent = $indent – 1;
// Create the image
$im = imagecreatefrompng(“$buttonbg”);
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
$red = imagecolorallocate($im, 255, 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, 24, 0, $shadowindent, 44, $white, $font, $text);
// Add some shine to the text
imagettftext($im, 24, 0, $reflectindent, 42, $black, $font, $text);
// Add the text
imagettftext($im, 24, 0, $indent, 43, $red, $font, $text);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>
The other codes are almost the same.