Results 1 to 2 of 2

Thread: [RESOLVED] PHP Images ALign text within Image?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Resolved [RESOLVED] PHP Images ALign text within Image?

    I'm loading text on to a png file of width xWidth and height xHeight.

    Can anyone think of a way to work out the x/y position so that the text is aligned?

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: PHP Images ALign text within Image?

    SOlution...

    PHP Code:
    $bbox imagettfbbox (100$font$text);

    $textLength $bbox[2] - $bbox[0];
    $centreDocument $imgWidth 2;
    $x $centreDocument - ($textLength 2);

    imagettftext($im100$x20$black$font$text); 

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