TextImage plugin for WordPress
The TextImage plugin for WordPress displays your post text as a PNG image instead of sending it to the browser as normal HTML. You can specify the text color, background color, font, font size, and image width you want to use.
Why would you want to do this? Text rendered as an image can’t be read by most robots and filters. TextImage can help ensure that your posts won’t be found by search engines and the like. If you want your posts to have the widest audience possible, TextImage probably isn’t for you. If you want to maintain a weblog for a private community and keep a low profile, TextImage might help.
The idea for the TextImage plugin came to me when I read about the Great Firewall of China. This Internet censorship regime uses automated filtering to accomplish most of its dirty work. Something like TextImage might help get real information past this kind of robotic tyranny, though of course it will be useless against human censors.
Requirements
TextImage was written and tested using WordPress 2.1. I have not tested it with other versions.
TextImage requires the gd module for PHP. If phpinfo() has a section for the gd module, you’re probably OK. On my CentOS 4.3 server, I used the command yum install php-gd to get the correct module installed. TextImage tries to detect whether gd is installed, and if it isn’t, TextImage won’t try to change the way WordPress displays your posts.
TextImage also needs TrueType fonts. These are files with the extension .ttf. There are probably hundreds of them on your Windows machine under /windows/fonts. There are also websites that sell TrueType fonts, or let you download them for free.
If your Linux server has a graphical interface installed, it probably also has some TrueType fonts. TextImage looks for them under /usr/shared/fonts. If your fonts aren’t there you will need to change the value of the variable $textimage_font_directory at the top of textimage_wp.php.
Installation
The TextImage plugin for WordPress consists of two files. All of the WordPress-specific code is in textimage_wp.php. The creation of the actual image with word-wrapped text is done in wrapped_text_image.php. Just copy both files to the wp-content/plugins directory, then enable the TextImage plugin on the Plugins admin panel. All your posts will henceforth appear as images. Nothing is changed permanently: deactivate the plugin and they’ll reappear as normal.
Options
TextImage installs its options page under the Options tab, as you might expect. The options you can specify are:
| Option |
Description |
| Image cache directory |
Where TextImage to save images. This directory must be writable by WordPress. Include the trailing slash. |
| Image cache URL |
The relative or absolute URL to the image cache directory. |
| Image width |
How wide to make the image, in pixels |
| Font height |
How large to make the font, in points |
| Text color, Background color |
The RGB color specified as a number – either hex (0xRRGGBB) or decimal will work |
| Font |
The ttf font file to use. TextImage generates a list of all the ttf files under /usr/shared/fonts. |
| Clear image cache |
Check this box if you want TextImage to delete all the previously-saved PNG files. Do this if you want all your posts to display using the new options. |
Limitations
TextImage does not render HTML: it can’t apply multiple fonts, bolding and italics (unless everything is bold or italic), or other fancy formatting to your post. You get one font in one size and color. You can, however, force line breaks by using carriage returns.
TextImage strips html tags from your post before it renders the image. It does not, however, modify the actual post. If you disable TextImage, all your HTML will work as before.
The current word-wrap algorithm sometimes seems to make line shorter than they need to be. I’ll look into fixing this.
TextImage renders only posts as images. Titles, comments, and all other content are still rendered as regular HTML. If there is demand I might consider changing this.
As you can see from the image for this post, tables and other heavily formatted text won’t render correctly in TextImage.