Fit text of any length into image of fixed dimensions
coding.pressbin.com
coding.pressbin.com
There should be a whole bunch of escapeshellarg() in there. Who knows what the text contains? Code like this is exactly why PHP devs get a bad rep. Please don't post PHP code online unless you've made it reasonably secure, because somebody somewhere is going to copy that and get pwned.
Also, why not use PHP's own imagick extension? It exposes a neat object-oriented interface, it will be much easier for people to read and tweak, and you won't have to escape anything.
but I fear that those most likely to just grab this code and run with it, are the least likely to even notice that page, let alone heed its (nonspecific) advice.
If I ever start a technical blog, I'm going to style the <code> element so that every code sample automatically gets a link to a disclaimer about security, copyright, etc. Also throw in class="insecure" (background-color: reddish) to any sample which I know should never be used in production.