I love coming up with programmatic ways to solve problems. Recently I was creating something called "The Orb" in SecondLife. Basically The Orb is like a pet that follows a avatar around and does useful (and sometimes blingy) kinds of things. The Orb is in reality just a hollow 3D sphere but I wanted to jazz it up a bit. What I needed was animated textures.
After a little bit of time searching the LSL wiki I realized the problems inherent in how SecondLife animate texture. To animate a texture in the game you call a function like the following:
llSetTextureAnim(integer mode, integer side, integer x_frames, integer y_frames, float start, float length, float rate);
The texture (already loaded on the 3D sphere) is in the form of the frames of the animation placed in the same texture one below the other (see picture at left). This caused me some grief. All I had were the individual frames (in the form of png files). I was going to be doing 10-15 of these animations and I did not want to manually place these "frames" in the same file. I knew about a set of cross platform utilities called ImageMagick that could be used to transform over 90 image formats. I really was hoping it could help me. Sure enough, it did.
ImageMagick contains a utility called convert.exe. This command line utility has a multitude of functions that can be used on a single image or a series of images. By using the command:
convert -append *.png
I soon had a directory of pngs converted to a single png with the "frames" of a animation stacked one on top of another. Voila. ImageMagick to the rescue.