You can use ImageMagick to convert images in varying ways, and it should be able to this quite easily. First you can split up into to parts (original.png
being the source image, and in this case 32x32pixels in size):
convert original.png -crop 32x32 parts-%02d.png
You can then convert it into a animation (use -loop 1
if you don't want it to loop):
convert -loop 0 -page +0+0 ./parts*.png output.gif
Resulting in:
The output PNGs of the first command have a offset included in them, so without the -page +0+0
option the animation ends up like:
There are varying other options you can include (mainly in the second command), such as -delay
etc - you can also optimize the animation so it is smaller (and faster to load/render) - e.g. borrowed from here:
convert output.gif -fuzz 10% -layers Optimize optimised.gif
or using gifsicle
gifsicle -O output.gif -o optimised.gif
EDIT: If the frames are transparent, you can set the frames to replace by adding the
-dispose Background
option, so when a frame is disposed of when the next one is loaded:
Example above done without the page
option so it shows clearly
The problem with this is you probably can't optimize the resulting image much then - so another way may be to make the frames opaque so the next frame covers the previous.
Best Answer
ImageOptim uses Gifsicle for its Gif compression. As far as I know, it works quite well (I don't generally use Gif these days). From their site: