Draw a Button Image in PHP
Description
The following code shows how to draw a Button Image.
Example
<?php/* w w w .j a va 2 s. com*/
$font = 3;
$image_height = intval(imageFontHeight($font) * 2);
$image_width = intval(strlen("java2s.com") * imageFontWidth($font) * 1.3);
$image = imageCreate($image_width, $image_height);
$back_color = imageColorAllocate($image, 216, 216, 216);
$text_color = imageColorAllocate($image, 0, 0, 255);
$rect_color = imageColorAllocate($image, 0, 0, 0);
$x = ($image_width - (imageFontWidth($font) * strlen($_GET['button']))) / 2;
$y = ($image_height - imageFontHeight($font)) / 2;
imageString($image, $font, $x, $y, "java2s.com", $text_color);
imageRectangle($image, 0, 0, imageSX($image) - 1, imageSY($image) - 1, $rect_color);
header('Content-Type: image/png');
imagePNG($image);
imageDestroy($image);
?>