Chapter 10. Web Graphics Cookbook

Several idioms have evolved on the Web that are worth examining in depth; the phenomenon of web counters, for example, or the culture of web cams. This chapter provides some reusable examples of common web graphics applications:

  • The BrokenImage module that enables Perl-based CGI scripts that generate graphics to present error messages to a web browser rather than a generic broken image icon.

  • A web page access counter that will be updated every time a user views the page. Even though some people rail against counters, they are still a much asked-for feature by new web authors.

  • A JavaScript rollover example, because rollovers are also a much requested feature, and they are too widely used to be ignored.

  • A Web Cam how-to.

  • A section on providing ASCII ALT attributes so that your images may be viewed in some approximation by text-only browsers.

  • Thumbnailing scripts that will ease the tedium of making thumbnails of large groups of images.

Each recipe is broken down into three sections: a discussion of the problem, what is required for the example, and a discussion of a possible solution or implementation.

The BrokenImage Module

A web page that accesses a dynamically generated image runs the risk of displaying uninformative “broken” images if the script that generates the image fails to successfully complete its operation. The fact that an <IMG> element that calls a script from its SRC attribute expects a valid stream of image headers and data can make it ...

Get Programming Web Graphics with Perl and GNU Softwar now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.