[Solved] Convert animated gifs to sprite sheets

I have a shell scripting request. I haven’t spent much time figuring it out myself yet, but I want to try and convert animated gifs into sprite sheets for use in SDL game development. I know how to break an animated gif into a series of images: convert animation.gif target.png, but not how to string them together end to end, in a single image file.

Is there a shell command that can help me create a single sprite sheet out of multiple images?

Enquirer: j0h


Solution #1:

It seems you have ImageMagick binaries installed already, so you can use the following command:

$ montage your_gif.gif -tile x1 -geometry +0+0 -alpha On -background "rgba(0, 0, 0, 0.0)" -quality 100 sprites.png

That should create a file named sprites.png, with the gif’s frames.

Respondent: aanc

Solution #2:

Here is a start on a solution I made:
its has some bugs. I want to add a function to create whole directories into sprite sheets.

#Convert animated gif to sprite sheet
#pass in animated gif get out png sprite sheet
convert $1 $1.png
convert `ls *.png` +append $1.png.result
rm *.png
mv $1.png.result $1.png
Respondent: j0h

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Leave a Reply

Your email address will not be published.