I would like the script to resize the font to fit the image.... is this possible? If not, I'll have to restrain the user from making the string too long.
Code: Select all
<?php
if(empty($_GET['text'])) {
$_GET['text'] = 'No text defined.';
}
$_GET['text'] = html_entity_decode(urldecode($_GET['text']));
$im = imagecreate(550, 50) or die("Cannot Initialize new GD image stream");
$top = imagecreatefrompng('top.png');
$background_color = imagecolorallocate($im, 255, 255, 0); //RGB color background.
$text_color = imagecolorallocate($im, 40, 40, 40); //RGB color text.
$shadow_color = imagecolorallocate($im, 200, 200, 200); //RGB color text shadow.
$border_color = imagecolorallocate($im, 0, 0, 0); //RGB color border.
imagefilledrectangle($im, 0, 0, 550, 50, $border_color);
imagefilledrectangle($im, 2, 2, 547, 47, $background_color);
//bool imagecopy ( resource $dst_im , resource $src_im , int $dst_x , int $dst_y , int $src_x , int $src_y , int $src_w , int $src_h )
imagecopy($im,$top, 4,4,0,0,44,44);
imagettftext($im, 30, 0, 51, 40, $shadow_color, './fonts/Futura.ttf', $_GET['text']);
imagettftext($im, 30, 0, 48, 40, $text_color, './fonts/Futura.ttf', $_GET['text']);
header("Content-type: image/png");
return imagepng($im);
imagedestroy($im);