PDA

View Full Version : Expanding Image With Text (GD)



: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&#181;ke (Forum Moderator): Thread Moved From Website Designing. Please post in the correct section next time, Thanks :).

redtom
28-02-2007, 08:37 PM
I'm not sure but I think you need .htaccess, because the image needs to be displayed as yourimagename.png on the .php page, so when you right click it and propertes the end is .png not .php, also this should be in coding.

:Edzy
28-02-2007, 09:51 PM
the ownage blob guys one is .php :S

ScottDiamond
28-02-2007, 10:11 PM
the ownage blob guys one is .php :S

That made me LOL in real.

PM Blob asking him nicely. :]

redtom
28-02-2007, 10:16 PM
If you find out please tell me, because atm people have to save the images they make then upload them to a hosting site.

timROGERS
01-03-2007, 07:42 AM
If you find out please tell me, because atm people have to save the images they make then upload them to a hosting site.

If you wanna save an image you've generated, do this for example:


imagegif($imagehandle, "filename.gif");

:Edzy
01-03-2007, 05:40 PM
That made me LOL in real.

PM Blob asking him nicely. :]

ive asked him on msn for help and he sent me to pixel2life which helped me make this so far and i then asked him if i could use his and he sed he couldnt coz of his co-owner of his site dont want it given out which is fair enough lolz

Invent
01-03-2007, 05:50 PM
And that would be me (: (co-owner).

:Edzy
01-03-2007, 05:54 PM
And that would be me (: (co-owner).

Do You Give Into Begging ;)

Blob
01-03-2007, 05:57 PM
Lol, speak to me on MSN around 6:30 PM. Im not on my computer at mo.

:Edzy
01-03-2007, 05:59 PM
Lol, speak to me on MSN around 6:30 PM. Im not on my computer at mo.

o.O kkkzzz <33

:Edzy
02-03-2007, 05:57 PM
Cheers All xD

Want to hide these adverts? Register an account for free!