Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts

    Wordwrap using ImageString()

    I am using imagestring() to dynamically write onto image that I have. I have a problem where I want to write only in a specific part of my image.

    Like if my string is longer than my image, I don't want my string to run off the edge of my image. I am searching for a way to have my string wrap to the next line. Any suggestions?
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.

  • #2
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts

    No Takers??

    I guess I'll have to find out the maximum amount of characters I have before my string falls off my image.......use something like strlen() and if my string is too long.....use something like strrpos() to find the last safe " " ....cut my string........and then use the imagestring() at a new y coordinate and repeat the process as necessary.

    I know this might not be perfect logic off the top of my head. But I'll try to write this as a function and post for anyone else to use if interested.
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.

  • #3
    Regular Coder ralph l mayo's Avatar
    Join Date
    Nov 2005
    Posts
    951
    Thanks
    1
    Thanked 31 Times in 29 Posts
    http://us3.php.net/wordwrap

    Your image width should be imagefontwidth(integer value of the font you're using) * the number of chars you are wrapping at or the length of the string, whichever is less + any padding you want.
    Last edited by ralph l mayo; 02-17-2006 at 03:38 AM.


  •  

    Posting Permissions

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