Jump to content

Dynamic image script that handles text wrapping?


tibberous

Recommended Posts

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.