tibberous Posted March 30, 2011 Share Posted March 30, 2011 I am looking for a dynamic image script that handles word wrapping and possible font resizing. Basically, I have a dimensions, a font and a company name. So, lets say I am trying to make a 300x300 image for Bob's Boats in verdana. I want a script that not only creates the image, but tries to use up the available space (putting each word on a line, using a large font, horizontally and vertically aligning everything) Worst case I'll write my own, but the algorithm seems pretty complex. For example, lets say the companies name was: Chocolates in a Basket, it could be: Chocolates in a Basket Or: Chocolates in a Basket But never: Chocolates in a Basket Worst case, I might make it so that it supports 3 lines, but only ever puts the company name on 2 by default, and if the user wants to manually change it, they can. Even that isn't perfect though, because if the dimensions are something like 300x35, you wouldn't want a second line, let alone a 3rd. Quote Link to comment Share on other sites More sharing options...
gizmola Posted March 30, 2011 Share Posted March 30, 2011 The key to figuring this out is: http://us.php.net/manual/en/function.imageftbbox.php There are some notes on the manual page you may find helpful. Quote Link to comment Share on other sites More sharing options...
tibberous Posted March 30, 2011 Author Share Posted March 30, 2011 Yeah - I know how you'd do it, just was hoping someone already did. Might just write it so that it only does one or two lines, which makes the problem quite a bit easier. Still going to be a couple pages of code. Quote Link to comment Share on other sites More sharing options...
gizmola Posted March 30, 2011 Share Posted March 30, 2011 Yes, however, in the notes of the page, you might take a look at this link: http://www.printsmadeeasy.com/code_samples/php/text_generation.html The guy wrote some fairly sophisticated code you can get from his link that looks like it might fit your need, or at least provide a starting point. It purports to do what you are asking for. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.