You need to look at the
GD distribution. You can create PNG and JPeg images with the appropriate support libraries.
The main library is supported
here. But you'll also need the Perl modules from CPAN. If you are running on Windows then you should be able to get a ppm for it all.