[Skip top navbar]

Andrew Gregory's Web Pages

Rocky outcrop at sunset, Approx 27°56'15"S 119°38'17"E

-

Message Image


Introduction

This is a Perl script that generates GIF images of short text messages:

Message Image

It's main use would be to protect forms from automated submission. For example, guestbooks, forum registration, mailing list subscriptions, etc.

The script has no external dependencies and does not utilize the LZW compression algorithm, thereby eliminating any possible patent issues. The generated images are therefore uncompressed.


Download

Creative Commons License
This work is licensed under a Creative Commons License.


Background

Around late September, early October of 2003, the developers of the YaBB bulletin board (forum) software were testing a new board registration system. One of the new features was a system to stop automatic registration of new users onto the forum. The implementation they were testing used a script to generate a text message image. Each 'pixel' in the image was a separate image file! As you can imagine, the resulting HTML code was huge, plus the image tended to break up in some browsers, rendering the message unreadable.

I realised this could be solved by turning all the little images into a single image. The problem was that the forum software code must be pure Perl, using little, if any, external modules to maximize cross-platform operability. The compression algorithm used in GIF files is quite complicated and normally requires the use of at least a compiled program to work at acceptable speeds. A pure Perl implementation of the compression algorithm didn't seem to be practical.

Many years ago I had developed a C library to encode and decode GIF images. From that experience I knew it was possible to bypass the compression algorithm and produce working GIF files that were uncompressed. That was much simpler and could be done in pure Perl. This script was born!


Use as a CAPTCHA

  1. Install my msgimg.pl script.
  2. Create a script similar to my msgimgdemo.pl that creates a special string of characters for the CAPTCHA. That string should encode something specific to the visitor of your page, such as their IP address, the time, their user agent, etc.
  3. Add an <img> to your form that refers to the above script, and add a text field asking people to enter what they see.
  4. Modifiy the script that checks the submitted data to decode the text people entered for the CAPTCHA and extract the encoded info, i.e. the IP address, the time, etc. It then compares that to the IP address and time for the submitted data. If the data matches (i.e. the IP address is the same, the times are within a few minutes), the data is accepted, otherwise they are sent back to the form to correct their entries.

Known Users

YaBB

YaBB is a web forum system written purely in Perl. If you want to run a web forum, but don't have database support (like MySql) available, then YaBB is the best solution around. It's full-featured, has good performance, and is very simple to set up and administer. Check it out (even if you do have database support).


Credits

Apple Computer Inc. for the Apple IIe ROM character set. Used without permission (but I'm sure they won't mind).


Alternatives

ImageMagick - A comprehensive library available for a wide variety of languages and platforms. Much more powerful than my script, but only useful if you can install software on your web server.


Version History

Message Image Script Version History
VersionDateDescription
1.52007-02-17
  • Now supports variable bits per pixel and defaults to 16-colour images.
1.42006-05-11
  • Changed pack usage from platform dependent 's' to 'v'.
1.32004-12-03
  • Added multi-line support. Separate lines with newlines ("\n").
1.22004-07-16
  • Reviewed all glyphs. They all match the Apple IIe ROM text glyphs now.
  • Reduced the random noise slightly.
1.12004-06-12
  • Split image generator from demo code.
  • Added random noise.
1.02003-10-11
  • Doubled speed.
0.x2003-10-06
  • Tidied up script.
0.x2003-09-??
  • Early testing versions.

-