The magazine of the Melbourne PC User Group
Perl Graphics Programming
- For the bookshelf
Major Keary |
|
The word 'graphic' has been in the language as an adjective since the 1600s, but
its use as a noun dates from the late 1800s when it meant, the technical use of
diagrams and figures as an aid to mathematical calculation or to engineering or
architectural design [Oxford English Dictionary]. Later (1960) it took on the
meaning, design and decoration that involves typographic elements; the
production of pictures, diagrams, etc., in association with text [OED]. Shortly
after (1966) 'graphics' became associated with computer programs: a diagram,
pattern, picture, etc., produced by means of a computer [OED].
The kind of graphics available in 1966 were quite primitive when compared with
what can be done now. Some people seem to take the view that any
computer-generated communication should be accompanied - or even dominated - by
graphics. Graphics have become an important feature of Web design, which creates
a problem: finding the resources to create and display graphics.
Graphics programming for the Web has become a field in its own right, which is
demonstrated by O'Reilly's recent title, Perl Graphics Programming. The author
says of this thorough treatment of graphics programming, it "is not really
geared at graphics programmers . a typical user could be someone who already
knows Perl and is handed a job that requires thousands of pieces of text from a
database to be pieced together into a collection of PDF files . or it could be a
Webmaster who wants to dynamically generate SVG/PNG/JPEG/GIF/etc. files from CGI
scripts". There is an assumption that the reader is familiar with Perl.
Perl has enormous potential for automating graphics tasks, and for anyone with a
serious interest in graphics - whether Web-related or not - Perl Graphics
Programming is well worth reading. It is a resource for that focusses on the
creation and manipulation of "images and structured documents with Perl,
allowing you to add graphics, Flash animations, PDF reports, and more to your
programs". It shows how to use The Gimp (the UNIX/Linux answer to Photoshop) and
"how to create PostScript and PDF files for forms and reports".
PostScript and PDF? Perl Graphics Programming has a chapter on PostScript, which
shows how Perl can be used to "develop a framework for easily creating
PostScript code from Perl scripts. These modules are useful for creating
printable reports from various data sources, and could even be used as the
backend of a Perl-based page layout application". It also shows how to create
printable documents from CGI scripts, such as an automated invoice system.
A Perl module, PDF::API2, can be used to dynamically create new PDF documents or
manipulate existing PDF documents. Anyone who uses the PDF format will know that
making non-trivial changes to an existing PDF file is not easy, even with the
full Acrobat package. The book contains an interesting discussion of the PDF
file structure and its operators, and shows how to add to an existing PDF file.
There are in-depth discussions of Perl's drawing modules, among which are Perl
interfaces to the ImageMagick C library and the Gimp (GNU image manipulation
program). Perl can also be used to create SVG (scalable vector graphics) images,
and to introduce text into SVG files using Unicode.
The book is in parts. Part 1, Raster Images and Web Graphics, shows how to use
the GD module (image drawing and manipulation tools, fonts, and graphing),
graphics scripting with ImageMagic, and scripting the Gimp.
Part 2, Vector Images and Animation, describes two image formats, SVG and SWF (ShockWave/Flash,
the format used by Macromedia Flash), and how to use Ming to create SWF files.
"Ming is a library written in C that provides a simple API for creating SWF
files", and comes with interfaces to Perl, Python, Ruby, Java and C++.
Part 3, Documents and Printing, contains the PostScript and PDF discussions.
Appendices include a Gimp reference and an ActionScript reference.
Anyone interested in the technical innards of SVG, SWF, PDF, and PostScript
formats will find information here that is not usually found in other graphics
texts. There is a lot of example code, and extensive reference material relating
to the various Perl modules.
Shawn Wallace: Perl Graphics Programming
ISBN 0-596-00219-X
Published by O'Reilly, 462 pp.,
RRP $95.00 incl. GST |
 |
Best of Perl Journal
This title is one of three volumes in which O'Reilly has brought together the "crème
de la crème of the 247 articles published during the Perl Journal's 5-year
existence as a standalone magazine". This 'volume' contains thirty-nine articles
spanning three topics: Web (just over half of the book), graphics, and Perl/Tk.
The articles were written as stand alone pieces, so each one has its own
introduction. Where there is a thread the order has been preserved, and where
several articles relate to a common topic they have been arranged in the best
order for reading. For example, in Part 1 (which focusses on the Web), the first
article is an introduction to CGI programming and the following ones deal with
cookies, saving the CGI state, and a thread on mod_perl (which overcomes the
limitations of CGI scripts). A fully functional Perl interpreter, mod_perl, is
embedded in Apache and can be used for all sorts of things, from setting up a
proxy server to authentication.
Another Web-related topic is "Wireless Surfing with WAP and WML", which
discusses wireless Web browsers and other matters of interest to wireless
aficionados - such as a remote control for home automation.
The articles on graphics include Web plots with Gnuplot, GD and L-Systems, ray
tracing, the Gimp, Glade, and capturing video in real time. Microsoft Windows
users may wonder what some of those names mean, but they will be familiar to
UNIX and Linux folk. Gnuplot is a graphing program, and the example of its use
with Perl is a plot of the hourly breakdown of visits to a Web site for capacity
planning. GD is a Perl module that "reads, manipulates, and writes PNG and JPEG
files . [it] has become the de facto graphics manipulation module for Perl".
L-Systems has been around since the late 1960s; it is "a very abstract way of
modelling cell-scale growth within a plant". Usually objects modelled with
L-Systems are rendered with turtle graphics, created for LOGO. The article
describes some neat, and fascinating, applications of L-Systems. Gimp is an
acronym for GNU Image Manipulation Program, and is usually referred to as 'the
Gimp'.
It is the UNIX/Linux equivalent of Photoshop, and the article describes its use
in conjunction with Perl, which has a Gimp module. Glade is "a free user
interface builder" for developers.
Perl/Tk refers to the toolkit module, which is fully covered in Mastering Perl/Tk
(an O'Reilly publication that is also included in the Perl CD Bookshelf). The
articles included in Web, Graphics, & Perl/Tk are pitched at users who are new
to Perl/Tk; they may be introductory, but some familiarity with Perl is assumed.
For anyone with an interest in any of the topics covered - especially Web
technologies and graphics - this book is well worth browsing. If you would like
to see examples of Perl at work this is a pleasant, readable introduction. For
Perl users it offers a wide range of practical applications and discussions.
Jon Orwant, ed.: Web, Graphics, & Perl/Tk
ISBN 0-596-00311-0
Published by O'Reilly, 432 pp.,
RRP $95.00 incl. GST |
 |
Reprinted from the September 2003 issue of PC Update, the magazine of Melbourne PC User Group, Australia
|