Results 1 to 3 of 3

Thread: [RESOLVED] Question about imagecreate

  1. #1

    Thread Starter
    Addicted Member Kal-El's Avatar
    Join Date
    Jun 2007
    Location
    Fortress of solitude
    Posts
    179

    Resolved [RESOLVED] Question about imagecreate

    This is my code:
    PHP Code:
    $text_array = array("Joel""Almeida""García""Joel Almeida García");
    $text $text_array[rand(0count($text_array)-1)];

    $im imagecreate(5022);
    $bgColor imagecolorallocate($im255255255);
    $fgColor imagecolorallocate($im,   0,   00);
    imagecolortransparent($im$bgColor);
    imagestring($im200$text$fgColor);
    header('Content-Type: image/png');
    imagepng($im);
    imagedestroy($im); 
    The above code, creates a png image from a random text....my question is: How can I calculate, by code, the corrrect values width and height of imagecreate, based on the returned text?

    Thanks

    «Source Code»«plugins»«skin»«fav apps»«Winamp en español»«Nsis en español»
    So what if your signature move is driving a tractor? I think it's adorable. - Lois ("Crimson")
    Don't forget to when your question is resolved ...and the people who help

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Question about imagecreate

    You can use imagefontwidth() and imagefontheight() to get the dimensions of a character in a particular font, and then multiply those figures by the length of your text.

  3. #3

    Thread Starter
    Addicted Member Kal-El's Avatar
    Join Date
    Jun 2007
    Location
    Fortress of solitude
    Posts
    179

    Re: Question about imagecreate

    Cool! Thanks for the tip

    «Source Code»«plugins»«skin»«fav apps»«Winamp en español»«Nsis en español»
    So what if your signature move is driving a tractor? I think it's adorable. - Lois ("Crimson")
    Don't forget to when your question is resolved ...and the people who help

Posting Permissions

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



Click Here to Expand Forum to Full Width