WWW FAQ: How can I generate GIFs on the fly from my CGI scripts?

How can I generate GIFs on the fly from my CGI scripts?

If you want to generate GIF images on the fly as part of your application, examine the gd library (URL is: http://www.boutell.com/gd/ ). Hint: your HTML page and your inline images are separate documents with separate URLs. Generate them in response to separate requests! (Yes, there are tricks to speed this up, but be careful not to break inline images on HTML pages you didn't write that refer to your gd-generated image.)

Adaptations of gd are available for Tcl, Perl, Python, and other languages. See the gd page, listed above, for more information.

Macintosh users should look into clip2gif (available by anonymous FTP from orathost.cfa.ilstu.edu in the directory /public/oratClasses/ART389.88Seminar/software and from many other sites including Info-Mac in the directory gst/grf). clip2gif supports assembling images from other images via AppleScript.

Perl users may also be interested in pgperl <URL:http://www.ast.cam.ac.uk/~kgb/pgperl.html>, an extended version of Perl which supports GIF output and can be used to good effect in CGI applications.

It's also possible to use gnuplot and the pbmplus utilities. These approaches is slower, but can require less programming if gnuplot is sufficient for your purposes. (See archie for both tools.)

World Wide Web FAQ