Results 1 to 4 of 4

Thread: [PHP] Can't use ImageTTFText();

  1. #1
    Join Date
    Oct 2006
    Posts
    206
    Mentioned
    2 Post(s)
    Quoted
    45 Post(s)

    Default [PHP] Can't use ImageTTFText();

    Hi guys,

    i'm trying to create my dynamic signature. Everything went well except for the fact that I cannot use ImageTTFText();

    Temoporarily I use Imagestring(); atm. This is the result:

    http://puu.sh/1JDNv


    My problem:

    This is my source code:

    Code:
    <?PHP
      header('Content-Disposition: filename=sig.png');
        header('Content-Type: image/png');
        function formatMilliseconds($milliseconds) {
                $seconds = floor($milliseconds / 1000);
                $minutes = floor($seconds / 60);
            $hours = floor($minutes / 60);
            $days = floor($hours / 24);
            $milliseconds = $milliseconds % 1000;
                $seconds = $seconds % 60;
            $minutes = $minutes % 60;
            $hours = $hours % 24;
    
                if($days == 0){
                $format = '    %uH %02uM %02uS';
                    $time = sprintf($format, $hours, $minutes, $seconds);
                    return rtrim($time, '0');
            }else{
                $format = '%uD %uH %02uM %02uS';
                    $time = sprintf($format, $days, $hours, $minutes, $seconds);
                    return rtrim($time, '0');
            }
    
        }
    
    
        $db_handle = mysql_connect($server, $user_name, $pass_word);
        $db_found = mysql_select_db($database, $db_handle);
    
    
        if ($db_found) {
    
            $SQL = "SELECT * FROM table1 WHERE ID=1";
            $result = mysql_query($SQL);
            if($result){
                while ($db_field = mysql_fetch_assoc($result)){
    
                    $xp = $db_field['XP'];
                    $time = $db_field['Time'];
                    $logs = $db_field['Logs'];
                }
    
    
    
                $image = 'sig.png';
                $img = imagecreatefrompng($image);
    
    
                $main_color = imagecolorallocate($img, 63, 55, 18);
              // putenv('GDFONTPATH=' . realpath('.'));
                
               // imagettftext ($img ,10,0,160,80, $main_color ,"public_html/arialblack.ttf", "imagettftexttest")
                imagestring($img ,5,160, 80,number_format($xp),$main_color);
                imagestring($img ,5,180 , 115,formatMilliseconds($time * 1000),$main_color);
                imagestring($img, 5,205,150,number_format($logs),$main_color);
                imagestring($img, 5,125,190,'Coming soon..',$main_color);
    
    
    
    
    
                imagepng($img);
                imagedestroy($img);
            }else
                        print "False";
    
        }
        else
            print "DB not Found, please report this";
    
    
    ?>

    the important section is this:

    Code:
        putenv('GDFONTPATH=' . realpath('.'));
                
               imagettftext ($img ,10,0,160,80, $main_color ,"public_html/arialblack.ttf", "imagettftexttest")
    whenever I run this piece of code this error pops up:

    http://puu.sh/1JDQP


    Anybody knows what the problem could be? i really would like to use ImageTTfText(); for a nicer font.

  2. #2
    Join Date
    Feb 2012
    Location
    DON'T PM ME ASKING FOR STUFF
    Posts
    2,170
    Mentioned
    38 Post(s)
    Quoted
    423 Post(s)

    Default

    well line 58 is blank for me weirdly.

    It's 2:30 am here, but I was thinking, you know you can still use custom fonts the other way right?

  3. #3
    Join Date
    Oct 2006
    Posts
    206
    Mentioned
    2 Post(s)
    Quoted
    45 Post(s)

    Default

    Quote Originally Posted by xtrapsp View Post
    well line 58 is blank for me weirdly.

    It's 2:30 am here, but I was thinking, you know you can still use custom fonts the other way right?
    I think line 58 is blank because I deleted the username/password lines.

    Could u please elaborate on how to? I can't find anything on it and i'm quite stuck on how to do this.

  4. #4
    Join Date
    Feb 2012
    Location
    DON'T PM ME ASKING FOR STUFF
    Posts
    2,170
    Mentioned
    38 Post(s)
    Quoted
    423 Post(s)

    Default

    Look in my signature for the 'updated' tutorial

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •