Sample Image::Magick Applications
ImageMagick can do almost anything to an image or group of images. Some common applications are:
Creating animated GIFs
Creating composite images from a sequence
Easily reducing or thumbnailing images
Setting transparent colors
Reducing and correcting colors
Converting between 60+ formats (e.g., Photo CD to JPEG, PDF to GIF, BMP to PNG)
Creating special effects and adding text to images
Examples of two of these applications are described in the following sections.
Thumbnails with Image::Magick
Suppose you have a bunch of image files (or PostScript or PDF files) for which you want to create smaller thumbnail images. The ImageMagick package provides several ways to do this. One high-level approach is ImageMagick’s Visual Image Directory virtual file format. You can convert a number of image files into a Visual Image Directory with the convert utility:
convert 'vid:*.gif' png:imageindex.png
This command converts every GIF file in the current directory into a single image that contains thumbnails of all the images, and saves it as a PNG file called imageindex.png. The resulting image looks like Figure 3-2.
The Visual Image Directory is essentially a high-level function that uses some of the lower-level ImageMagick routines to read in a bunch of images, scale them into thumbnails, provide ...
Get Perl Graphics Programming 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.