Seven Easy Pieces with PerlMagick
Because the PerlMagick module implements the full GIF89a specification and allows us to include multiple images in a single file, we will use it to create some useful solutions to common GIF animation problems. Two of the seven following “recipes” show examples of moving graphical elements called sprites around in an animation (Section 9.2.1 and Section 9.2.2); two illustrate some built-in features of PerlMagick that simplify certain tasks (Section 9.2.3 and Section 9.2.4); one is a utility script for breaking an image into a regular grid so that parts of it can be animated separately (Section 9.2.6); one shows a combination of image- splitting and applying an effect iteratively by allowing you to define a window through which a graphic can continuously scroll (Section 9.2.5); and the last example reconstructs a split image by generating an HTML table (Section 9.2.7).
But first, a quick review of PerlMagick concepts. PerlMagick uses an
object interface to its methods and attributes. An image object that
has been instantiated with new Image::Magick
can
read in image files of many formats with the Read(
)
method. An image object may be passed to another image
object with the Clone( )
method. Several images
can reside within the same image object. Each of these individual
images are referred to as scenes and can be
retrieved by treating the object as a reference to an array. For
example:
$image2 = $image1->[3]->Clone();
In this line, the image object ...
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.