Many people are fascinated by computer graphics. Computers are being used to create photo-realistic images of surreal scenes or fractally generated images of mountain ridges with lakes and valleys; to change images by bending, polishing, aging them; or to make any other manipulations.
Linux does not need to step shyly aside when it comes to graphics. It can do just about anything that other computing environments can do, and in some areas, like dealing with many graphics files at the same time, it even excels. The X Window System, described in the next chapter, forms a very good base for bitmapped graphics, while hardware support will eventually arrive for 3D graphics conforming to the OpenGL standard.
However, working with graphics on Linux is often different from what you might be used to from other operating systems; the Unix model of small, interoperating tools is in effect here, too. This philosophy is be illustrated most clearly with the suite of graphics manipulation programs ImageMagick that we will describe here. ImageMagick is a collection of tools that operate on graphics files and are started from the command line or from shell scripts. Imagine that you have two thousand files of one file format that you want to reduce to 256 colors, slant, and convert to another file format. On Linux, this is only a few lines in a shell script. Now imagine doing this on Windows: Click on the File menu, click on the Open menu entry, select a file, select an operation, specify the parameters for the operation in a dialog, click OK, choose save from the menu, select a filename, and then click OK. Now repeat for next 1999 files. Can you say RSI?
Graphics can not only be drawn but also programmed. There are tools like the ray-tracer POVRAY presented in this chapter where you specify the graphics to be generated by a suite of commands, often in a full-blown graphics-programming language. While this is perhaps more difficult than drawing the desired graphics with the mouse, it is also infinitely more flexible once you have mastered how to use it.
Now, not everybody wants to work with graphics from the command line. Part of the appeal of working with computer graphics is the immediate feedback when working with graphics programs, and Linux can provide these, too, even though those programs are currently in the minority on Linux (and perhaps will continue to be).
In this section, we will talk about some of the options for using and working with graphics on your Linux system. Most of the programs discussed here require the X Window System, which we'll show you how to install and configure in later chapters.
The programs we are covering here are:
There are many more graphics programs available for Linux, including 3D modelers and video players. Scouring some Linux archives will reveal a wealth of good software to you.
ImageMagick is a suite of programs that convert and manipulate graphics files from the command line. It is also well suited for batch conversions, that is, converting many files at once. In addition, ImageMagick includes PerlMagick, a binding that lets you invoke the ImageMagick utilities from the Perl programming language. It comes with most Linux distributions; if yours does not have it, you can get it from ftp://ftp.x.org/contrib/applications/ImageMagick.
ImageMagick consists of a library and a number of utilities:
To sum up, the programs from the ImageMagick suite are an extremely versatile means to manipulate graphics files. It takes some time to familiarize yourself with all the command-line options in order to know what is available.
9.4.2. The GIMP
The GIMP (which expands to either GNU Image Manipulation Program or General Image Manipulation Program and is often written with the definite article) specializes in image-manipulation like the ImageMagick package described in the last section. But while ImageMagick's strength is batch processing, GIMP does everything via its GUI. The GIMP is often cited as one of the most impressive and successful products for Linux (and other Unix versions). People who use image-manipulation programs professionally have said that while GIMP can feel a little bit awkward to use, it is functionally comparable to its commercial competitor from the Windows and Macintosh world, Adobe Photoshop. Some people even have called it "the free alternative to Photoshop."
GIMP draws its power from an amazing number of plug-ins that are available for it. Thus, in order to be able to use a newly written image manipulation filter or file format import filter, you only need to install the plug-in, restart GIMP, and you are ready to go.
In addition, GIMP uses a clever tiling mechanism that allows you to load arbitrarily large images into it; GIMP will keep in memory only the part that is currently being used or visible. And if these features are not enough, GIMP also has its own scripting language called script-fu.
GIMP comes with most Linux distributions on the market today and can be run simply by entering the command gimp in a shell after starting X. If your distribution does not have GIMP, you can get the source code from www.gimp.org. If you plan to do more work with GIMP, you should check this web site anyway, because it also contains the documentation and sample images that show off what you can do with GIMP. A screenshot showing the toolbar, dialog boxes, and a work area is shown in Figure 9-5.
Figure 9-5. The Gimp
While ImageMagick and GIMP are mainly for manipulating existing images, POVRAY (the first three letters stand for "Persistence Of Vision") is a program for automatically creating new images. It is a so-called ray-tracer; a program that computes a scene from some information about which objects should be in the scene, what their physical and optical properties are, where the light is coming from, and where the spectator is standing. You describe this to POVRAY in a programming language of its own.
This brief description should already indicate that using POVRAY is not something you learn in one afternoon. If you are interested in this program, you can download it from http://www.povray.org, which is also the first source for all kind of POVRAY resources like sample files, documentation, and so on. Since we could not give you even a crash course into using POVRAY here, we'll refrain from attempting this futile task.
Copyright © 2001 O'Reilly & Associates. All rights reserved.