Using the ImageMagick Utilities

The ImageMagick libraries come with a set of utility programs that are very handy to have around, and are just the thing for quick file conversions and image previewing. They also allow you to perform concise batch operations that would be much more time-consuming (if not impossible) with a GUI-based image manipulation program such as Photoshop or Paint Shop Pro. The four primary ImageMagick programs are display, animate, convert, and identify.

display

The display program is a utility for displaying an image on a workstation connected to an X server. It also offers a graphical interface to many of the ImageMagick image manipulation functions.

animate

The animate program is used for displaying a list of images as an animated sequence on a workstation connected to an X server. For example:

animate *.gif

would display all of the GIF images in the current directory as an animated sequence.

convert

The convert utility allows you to convert one image format to another. Most of the image manipulation functions may be applied during the conversion process. For instance, to convert a TIFF image of a quahog to a GIF image:

convert quahog.tiff gif:quahog.gif

To convert all of the GIF images in the current directory into a single, infinitely looping animated GIF named foo.gif with a half second delay between frames, use:

convert -loop 0 -delay 50 *.gif foo.gif

To create a GIF image using only the 216 web safe colors, try:

convert -map netscape: alpha.gif beta.gif

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.