Merge GIFs with gifsicle
Creating a GIF from a video is fairly simple at this point, as I pointed out in Convert Video to GIF or GIF to Video, but working with multiple GIFs is something many people would like to do. The top GIF manipulation library for years has been Gifsicle, so I looked toward Gifsicle for merging multiple animated GIF images.
Before you merge your GIFs, however, you'll want to ensure that they're the same size. Gifsicle has a
--crop option which crops images to a given size:
gifsicle --crop 300x300 ....
If you have GIFs of different sizes (i.e. you don't crop), the earlier GIF may show up behind subsequent GIFs, making for a sloppy image.
Additionally you may receive a gifsicle: warning: too many colors, using local colormaps error. To work around that error, you'll want to add
--colors 256 parameter when merge the GIFs.
So let's assume you have GIFs of the same size and you're ready to create your merged GIF. The following command will achieve the desired result:
gifsicle --crop 370x275 --colors 256 --merge first.gif second.gif -o merged.gif
You can use any number of GIFs and the outcome is a solid, single GIF. If you're a performance nut, you'll want to optimize the GIF as well!
Gifsicle continues to amaze me and I look forward to using the utility more. GIFs by nature are mostly for fun these days and Gifsicle makes that easy!