Creating an animated gif/mng from a sprite sheet

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
xanatos
Posts: 3
Joined: 2012-10-13T02:53:09-07:00
Authentication code: 67789

Creating an animated gif/mng from a sprite sheet

Post by xanatos »

I have a png sprite sheet (8 small frames put in this way: 12345678). I want to convert it to an animated gif and to an animated mng. The sprite sheet is 128x16. I want the frames to be 16x16.

I want to do it by command line, if possible in a single command.

I have tried something like:

convert -crop 16x16 +repage base.png -delay 20 -loop 0 result.gif

but the frames aren't animated "in place" (the animation is showed as: 1......., 12......, 123....., 1234...., 12345..., 123456.., 1234567., 12345678, 1......., where 1...8 are the frames and . is "blank")

Thanks a lot!
xanatos
Posts: 3
Joined: 2012-10-13T02:53:09-07:00
Authentication code: 67789

Re: Creating an animated gif/mng from a sprite sheet

Post by xanatos »

Found.

convert -dispose 3 -delay 20 -loop 0 base.png -crop 16x16 +repage result.gif

the order of the operators was wrong.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Creating an animated gif/mng from a sprite sheet

Post by fmw42 »

-dispose and -delay should come before the input image and -loop should be last before the output
xanatos
Posts: 3
Joined: 2012-10-13T02:53:09-07:00
Authentication code: 67789

Re: Creating an animated gif/mng from a sprite sheet

Post by xanatos »

fmw42 wrote:-dispose and -delay should come before the input image and -loop should be last before the output
Just checked... -loop can go where I put it or between the input file name and the output file name (I have used a -loop 2 to test this)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Creating an animated gif/mng from a sprite sheet

Post by fmw42 »

I am just going by Anthony's recommendations at http://www.imagemagick.org/Usage/anim_basics/#gif_anim

"As such I recommend that you always set "-loop" when creating a GIF animation, after all the images has been read in."
Post Reply