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?
2 Answers
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.pngThat should create a file named sprites.png, with the gif's frames.
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.
#!/bin/bash
#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