Writing multi-line text on image with PHP GD

Posted on under English, Tutorials

Beware! This post is more than 3 years old, it may be outdated or incorrect! Please check elsewhere for accurate information!

As some of you may know I've been working on a Opera-Mini like Open Source web proxy and PHP-based (with magical .NET technology) browser which can render css-less pages onto a "smart image" (format based on obml). After working on a closed-source rendering system it was stolen from me, I wanted to make a new one, based on PHP. So here are the first steps, rendering a multiline text on image with word wrapping and caching.

All you need is a writeable folder cache, a font.ttf font (I recommend a pixelated font rather than an anti-aliasted one if you're working with a small screen) and the PHP script itself. I didn't put any comments, as this script is not appropriate for those new to PHP, and anyone who wants to build a web page renderer in PHP surely must know PHP enough to understand all of the code without any comments.


This post was last updated on December 12th, 2013.