What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » PHP help needed

PHP help needed
Author: Message:
KeyStorm
Elite Member
*****

Avatar
Inn-sewer-ants-pollie-sea

Posts: 2156
Reputation: 45
38 / Male / –
Joined: Jan 2003
RE: PHP help needer
I did something like this for a shoutcast radio, let's see if it helps:

Variables you need:
$text: the actual string you want to output
$size: the size of the font
$angle: the angle of the font (0 for horizontal)
$maxlen: the maximum length that should be allowed (for 300px it's ok to set 290 in here)

code:
$slices = explode(' ',$text); 
                        $split = count($slices);
                        do{
                                $split--;
                                $out1 = NULL;
                                for($i=0;$i<=$split;$i++)
                                    {
                                        $out1 .= $slices[$i]." ";
                                    }
                               
                                $break = imagettfbbox($size,$angle,$fontpath,$out1);
                            } while ($break[2] > $maxlen);
$out2 = NULL;
                        for($j=$i; $j<count($slices); $j++)
                            {
                                $out2 .= $slices[$j].' ';
                            }


Once this is run, you will have following values:
$break[2] will tell you the width of the line
$out1 will be the first line and its width will be $break[2]
$out2 the second line

After this you can use both strings and print them into the image using imagettftext:

code:
$im = imagecreate($break[2]+10,50);
$background_color = imagecolorallocate($im, 100, 100, 100);
$text_color = imagecolorallocate($im, 000, 000, 200);
imagecolortransparent($im, $background_color);
imagettftext($img,$size,$angle, 5, 15, $text_color, $font, $out1."\n\r".$out2);
imagegif($im);
imagedestroy($im);


This may work, but if you are intending to do a transparent image with text you will get very ugly text borders. Either use a background or a PNG24 format.
04-17-2005 05:53 PM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
PHP help needed - by Ezra on 04-17-2005 at 05:22 PM
RE: PHP help needer - by KeyStorm on 04-17-2005 at 05:53 PM
RE: PHP help needer - by Ezra on 04-17-2005 at 07:32 PM
RE: PHP help needed - by KeyStorm on 04-17-2005 at 08:56 PM
RE: PHP help needed - by Ezra on 04-17-2005 at 09:25 PM
RE: PHP help needed - by KeyStorm on 04-17-2005 at 09:42 PM
RE: PHP help needed - by Ezra on 04-17-2005 at 09:47 PM
RE: PHP help needed - by KeyStorm on 04-17-2005 at 09:54 PM
RE: PHP help needed - by Ezra on 04-18-2005 at 12:07 PM
RE: PHP help needed - by KeyStorm on 04-18-2005 at 12:56 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On