Bildgröße dem Textanpassen

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Bildgröße dem Textanpassen

    Hallo,

    ich will einen beliebigen Text als Grafik ausgeben, und die Grafik soll genau so groß sein, wie der Text platz brauch.

    PHP Code:
        public function emailencoder_picture($strEmailAddress,$strFontColor '000000',$strBgColor 'CCCCCC',$strFontname 'sans-serif',$intFontsize 12)
        {
            
    header ("Content-type: image/png");
            
    $intImageWidth strlen($strEmailAddress)*ImageFontWidth($intFontsize);
            
    $intImageHeight ImageFontHeight($intFontsize);
            
    $objImage = @ImageCreate ($intImageWidth$intImageHeight);
            
    $objBgColor $this->emailencoder_Hex2RGB($strBgColor);
            
    $objBgColor ImageColorAllocate ($objImage$objBgColor['r'], $objBgColor['g'], $objBgColor['b']);
            
    $objFontColor $this->emailencoder_Hex2RGB($strFontColor);
            
    $objFontColor ImageColorAllocate ($objImage$objFontColor['r'], $objFontColor['g'], $objFontColor['b']);
            
    ImageTTFText ($objImage$intFontsize,0,5,15,$objFontColor,'../includes/fonts/'.$strFontname,$strEmailAddress);
            
    ImagePNG ($objImage);
        } 
    allerdings haut das mit verschiedenen Schriftgrößen nicht hin.
    Ich hab das Gefühl ImageFontWidth und ImageFontHeight geben nich das wieder was ich will...woher wissen die eigentlich welches Fonts ich nutze, denn da sind die größen ja immer unterschiedlich!

    Und imagefontload hat bei mir auch nicht so hingehauen. hat jemand eine Idee?

    Danke!

  • #2
    Schatzi, mußt halt die richtige Funktion benutzen!
    http://de2.php.net/manual/de/function.imagettfbbox.php

    Comment

    Working...
    X