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. Link to comment https://forums.phpfreaks.com/topic/232149-dynamic-image-script-that-handles-text-wrapping/ 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. Link to comment https://forums.phpfreaks.com/topic/232149-dynamic-image-script-that-handles-text-wrapping/#findComment-1194194 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. Link to comment https://forums.phpfreaks.com/topic/232149-dynamic-image-script-that-handles-text-wrapping/#findComment-1194253 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. Link to comment https://forums.phpfreaks.com/topic/232149-dynamic-image-script-that-handles-text-wrapping/#findComment-1194495 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.