Complex data can be really tricky to describe or interpret, and figures or graphics can be a big help. Lots of good commercial software is designed to create images or edit photographs, but what about open-source options? Popular GUI interfaces are fine for a few images at a time, but large-scale image processing is much more pleasant with command line tools.
Although the creation of programming graphics requires some initial code development, custom images can be created almost instantly. On the practical side, have you ever needed to edit a few digital microscopy images but didn’t want to install an expensive editing application? How about resizing thousands of photographs to display on a website? Or what about designing an image of a genome’s worth of chromosomes, on which you can overlay a variety of genome-scale data? We’ve found that free software can handle all of these practical tasks, including most image creation and analysis tasks, both complex and large-scale.
For powerful image creation and processing through a graphical interface, the GIMP is the way to go. Like most of this open-source graphics software, the GIMP (GNU Image Manipulation Program) was originally created for Unix systems but is now available for desktop operating systems too. It can do almost everything with bitmap graphics that commercial programs can do — and then some. These interfaces are organized very differently, however, so it takes a while to figure out where to find the right commands. We found that when in doubt, right-click on the image. The GIMP even comes with a “Script-Fu” menu that calls scripts, and power users can create their own — or modify, for example, the Coffee Stain command. Many of these scripts are of questionable utility (despite being fun toys), but you might find just what you want. Nevertheless, the core functionality of the GIMP is great.
To process lots of photographs or other images, ImageMagick is our favorite solution. ImageMagick is a command line application that can also be called through interfaces in all major programming languages. It comprises only a few commands, but some of them have more than a hundred options to do all sorts of image editing or creation. Supporting almost a hundred image formats, ImageMagick can be useful simply for converting between these. On the other hand, taking advantage of the software’s power requires looking around at help pages; some commands can go beyond the imagination. Simply writing a shell or Perl script to execute a similar ImageMagick command on every image in a directory can be a huge time-saver to resize, rotate, or systematically edit a collection of photographs.
To generate a bitmap figure from scratch, ImageMagick may be overkill, and Perl’s GD module may be the easiest solution. The GD module can read or write image files in PNG and GIF formats, both of which are understood by all Web browsers and graphics programs. The module draws lines, shapes, and text, which can be used to compose figures of unlimited complexity, such as those in genome browsers. This module has long been a staple of the Perl/CGI web world, since it’s so quick to generate images on the fly. GD’s low-level programming, however, means that it can take a lot of code to make the figure you want. For standard chart types, using GD-Graph can save some time for the programmer.
Bitmap images are fine for viewing in a Web browser, but if they’re resized and printed, they can get pixelated and ugly. One solution for generating publication-quality images is to use vector graphics. Whereas bitmap graphics comprise a matrix of pixels, vector graphics comprise objects made up of points. As a result, vector images can be rescaled with no loss in resolution. The open standard Scalable Vector Graphics is the most promising format. SVG uses XML to describe shapes, images, and text. As with bitmap graphics, SVG graphics can be created with both GUI-style drawing tools and programming interfaces. The main drawback of SVG is the slow adoption by Web browsers; users need to install a free SVG Viewer plug-in, which isn’t always straightforward. On the other hand, besides the quality of vector graphics and the ability to zoom in on an interesting part of the image, SVG also offers built-in scripting and animation.
To create SVG images through a GUI interface, a promising drawing tool is Inkscape, currently in version 0.4. It does a lot of what commercial programs can, but as with the GIMP, it takes a while to figure out where everything is. Most of our scientific colleagues find it takes longer to get comfortable with vector manipulation programs —whether Inkscape or a commercial application — than with bitmap editing programs, but these two types of graphical images provide such complementary strengths that it really helps to know how to create both.
SVG images can also be generated very effectively using programming tools. A traditional approach is the Perl SVG module. As with the GD module, one can compose an image with shapes, lines, and text. It pays to be careful with the SVG syntax, however, since one can generate files that make SVG viewers complain. It would be helpful if the module could understand SVG well enough to provide warnings and suggested corrections. For those who currently use GD to generate bitmap graphics but would like to convert to SVG, the most painless way is to switch to the GD-SVG module. GD-SVG adds an SVG wrapper around GD, so GD-based scripts only need replacing of the module name.
With expertise in open-source bitmap and vector graphics applications, both GUI-based and command line driven, one can create and edit just about any type of image, in any quantity. With the technical side of graphics under control, one can concentrate on the scientific and the artistic, designing images to best describe and interpret these ever-growing amounts of genomic data.
Fran Lewitter, PhD, is director of bioinformatics and research computing at Whitehead Institute for Biomedical Research. This column was written in collaboration with George Bell, PhD, a bioinformatics scientist in Fran’s group.