:Edzy
28-02-2007, 08:05 PM
How Would I Get My Image To Expand to the length of the text?
my current code is:
<?php
header('Content-type: image/png');
$text = $_GET['text'];
$im = imagecreatefrompng ("bg.png");
if($text == "ADMINISTRATOR"){ //if administrator
$color = imagecolorallocate($im, 255, 0, 0); //red
}
elseif($text == "Ed"){ //if moderator
$color = imagecolorallocate($im, 0, 0, 255); //blue
}
elseif($text == "JUNKIE"){ //if junkie
$color = imagecolorallocate($im, 0, 128, 0); //green
}
else { //something else...
$color = imagecolorallocate($im, 0, 0, 0); //black
}
$font = 'FL.ttf'; //font file
$fontsize = 30; //font size
$stringsize = imagettfbbox($fontsize, 0, $font, $text); //calculate the pixel of the string
$dx = (imagesx($im)) - (abs($stringsize[2]-$stringsize[0])) - 20; //calculate the location to start the text
imagettftext($im, $fontsize, 1, $dx, 50, $color, $font, $text);
imagepng($im);
imagedestroy($im);
?>
+Rep to all helpers
also how do i keep bg.png still transparent or not even use a bg.png
Edited by Lµke (Forum Moderator): Thread Moved From Website Designing. Please post in the correct section next time, Thanks :).
my current code is:
<?php
header('Content-type: image/png');
$text = $_GET['text'];
$im = imagecreatefrompng ("bg.png");
if($text == "ADMINISTRATOR"){ //if administrator
$color = imagecolorallocate($im, 255, 0, 0); //red
}
elseif($text == "Ed"){ //if moderator
$color = imagecolorallocate($im, 0, 0, 255); //blue
}
elseif($text == "JUNKIE"){ //if junkie
$color = imagecolorallocate($im, 0, 128, 0); //green
}
else { //something else...
$color = imagecolorallocate($im, 0, 0, 0); //black
}
$font = 'FL.ttf'; //font file
$fontsize = 30; //font size
$stringsize = imagettfbbox($fontsize, 0, $font, $text); //calculate the pixel of the string
$dx = (imagesx($im)) - (abs($stringsize[2]-$stringsize[0])) - 20; //calculate the location to start the text
imagettftext($im, $fontsize, 1, $dx, 50, $color, $font, $text);
imagepng($im);
imagedestroy($im);
?>
+Rep to all helpers
also how do i keep bg.png still transparent or not even use a bg.png
Edited by Lµke (Forum Moderator): Thread Moved From Website Designing. Please post in the correct section next time, Thanks :).