PHP Code:
$Text = "";
$Font = "tahoma.ttf";
$FontSize = "10";
header('Content-type: image/png');
$Image = imagecreatetruecolor(600, 600);
$White = imagecolorallocate($Image, 255, 255, 255);
$Black = imagecolorallocate($Image, 0, 0, 0);
imagecolortransparent($Image, $White);
imagefilledrectangle($Image, 0, 0, 600, 600, $White);
$TextBox = imagettftext($Image, $FontSize, 0, 0, 10, $Black, $Font, $Text);
$NewImage = imagecreatetruecolor($TextBox[2] , $TextBox[3]);
$White = imagecolorallocate($NewImage, 255, 255, 255);
$Black = imagecolorallocate($NewImage, 0, 0, 0);
imagecolortransparent($NewImage, $White);
imagefilledrectangle($NewImage, 0, 0, $TextBox[2], $TextBox[3], $White);
imagecopymerge($NewImage, $Image, 0, 0, 0, 0, $TextBox[2], $TextBox[3], 100);
imagepng($NewImage);
imagedestroy($NewImage);
Results 1 to 1 of 1
Thread: [PHP] Self Sizing Text Image
- 16 Nov. 2009 06:03am #1
- Age
- 30
- Join Date
- Nov. 2009
- Location
- Anaheim, California
- Posts
- 1,065
- Reputation
- 99
- LCash
- 500.00
[PHP] Self Sizing Text Image