I try to add text at the bottom of image and actually I\'ve done it, but in case of my text is longer then image width it is cut from both sides, to simplify I would like te
The accepted answer wraps text without measuring the font (max 40 characters, no matter what the font size and box width is), so the results are only approximate and may easily overfill or underfill the box.
Here is a simple library which solves the problem correctly: https://gist.github.com/turicas/1455973